• DSchach
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 11
    Replies
I'm testing code for a VF page, and I show an error message if there is no value in the ?Id= parameter. How do I write the test code for this? I can test with the Account I created in my test code, but this one line is keeping me from 100% coverage. Code is below:


----Apex Extension----

public with sharing class myExtension {

public Account account;
public Boolean isValid {get; set;}

public updateContactAddressesExtension(ApexPages.StandardController controller) {
this.account = (Account)controller.getRecord();
if (account.id == null )
{isValid = false;} else {isValid = true;}
...
}
}
...
}
I'm testing code for a VF page, and I show an error message if there is no value in the ?Id= parameter. How do I write the test code for this? I can test with the Account I created in my test code, but this one line is keeping me from 100% coverage. Code is below:


----Apex Extension----

public with sharing class myExtension {

public Account account;
public Boolean isValid {get; set;}

public updateContactAddressesExtension(ApexPages.StandardController controller) {
this.account = (Account)controller.getRecord();
if (account.id == null )
{isValid = false;} else {isValid = true;}
...
}
}
...
}
I am building a data entry form with 3 picklists--Account, Opportunity, and a custom child object of opportunity. The idea is you select an Account, and then get a picklist of all Opportunites, when you select an Opp, the child picklist shows up.

I built an interface like this in an scontrol and I'm now replacing it with VF.

I built a client object, which has an Account Id, Account Name, and a list of SelectOptions for available Opportunities:
public class client {
 public Id clientId;
 public String clientName {get{return clientName;} set{clientName = value;}}
 public List<SelectOption> projectOptions {get{return projectOptions;} 
set{projectOptions = value;}} public Map<Id,project> projects {get{return projects;} set{projects = value;}} public client() { projectOptions = new List<SelectOption>(); projects = new Map<Id,project>(); } }

On page load I build out a map of all my clients, each with it's projectOptions. When I debug the client object I get this:
001S0000003VuzSIAS=timesheetController.client: [
clientId=001S0000003VuzSIAS,
clientName=ONE/Northwest,
     projectOptions=(
          System.SelectOption[value="", label="- pick a project -", disabled="false"],     
          System.SelectOption[value="006S0000002JUkiIAG", label="ONE/Northwest 2008 Project", disabled="false"] ),
.
.
.

 But I can't get the project options to show in a picklist. The client picklist works, and when you change it, it rerenders the project section. But the project picklist is empty, and I can't get the project options that I know are there to show up.:

<tbody>
         
 <tr><th><apex:outputText value="AccountNew"/></th>
  <td>
   <apex:selectList value="{!newTaskLog.Account__c}" id="accountselect" 
multiselect="false" size="1"> <apex:selectOptions value="{!clientSelect}"/> <apex:actionSupport event="onchange"
action="{!setupFocusClient}" rerender="projectselect"/> </apex:selectList> </td></tr> <tr><th><apex:outputText value="ProjectNew"/></th> <td> <apex:outputPanel id="projectselect" > <apex:outputText value="{!focusClient.clientName}"/> <apex:selectList value="{!newTaskLog.Opportunity__c}"
multiselect="false" size="1"> <apex:selectOptions value="{!focusClient.projectOptions}"/> <apex:actionSupport event="onchange"
action="{!setupFocusProject}" rerender="taskSelect"/> </apex:selectList> </apex:outputPanel> </td></tr>

Any ideas about what I'm doing wrong?

Thanks,
Steve
 

Hi
 
I'm an advanced administrator but have absolutely no coding skills and am trying to teach myself some basic APEX and VisualForce.
I am having some difficulty understanding standard controller extensions and was hoping that someone can give me a little guidance here. I have scoured the discussion boards but have failed miserably in locating a post that I could understand so apologies in advance if this is a topic that has already been dealt with.
 
I'm trying to build a VF page that will allow users to mass update the Contacts on an Account e.g. phone numbers, flag as inactive etc.
 
My code:
 
public class accountContactList {
    public PageReference save() {
        return null;
    }

  public Account getAccount() {
    return [select id, name,
             (select id, name, firstName, lastName, title, phone, mobilePhone, email from Contacts limit 5)
             from Account where id =
             :ApexPages.currentPage().getParameters().get('Id') ];
}

public String getName() {
  return 'Account Contact List';
  }
}
 
My VF page:
<apex:page controller="accountContactList" tabStyle="Contact">


<apex:pageBlock title="Mass Edit Contacts">

</apex:pageBlock>

<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save" id="theButton"/>

</apex:pageBlockButtons>

<apex:pageBlockTable value="{!account.Contacts}"
var="contact">

<apex:column value="{!contact.name}" width="25" />
<apex:column headerValue="Title" width="100">
<apex:inputField value="{!contact.title}"/>
</apex:column>
<apex:column headerValue="Phone" width="15">
<apex:inputField value="{!contact.phone}"/>
</apex:column>
<apex:column headerValue="Mobile" width="15">
<apex:inputField value="{!contact.mobilephone}"/>
</apex:column>
<apex:column headerValue="E-Mail" width="25">
<apex:inputField value="{!contact.email}"/>
</apex:column>

</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>

</apex:page>
The above allows me to access and edit the Account's related Contact records but I am unable to save any changes I make
I have tried adding:
private final ApexPages.standardController the Controller
and
return theController.save();
to the Apex Class but without much success (as described in on p391 of the force.com Developer Guide that I picked up at Dreamforce '08)
Any help/guidance would be most appreciated.
Thanks in advance
I have a child object(Campaign Expenses) to the Campaign object through a lookup field. I have to have it as lookup as I already have a master-detail relationship to the Campaign Expenses table.

What methods can I use to SUM the campaign expenses in a campaign object formula field?
  • December 12, 2008
  • Like
  • 0
I am building a new custom detail button using some syntax that was posted within the community.  I've re-engineered the syntax to work in my environment and get no errors when I save/check the syntax.
 
The button lives on the opportunity and its intent is to create a new Project record. When I click on the button I get an Insufficient Privileges error which is odd since I am sys admin and I am able to create a new project and account without the use of the button.
 
I am guessing, that my syntax below has some residue that doesn't jive with my org. I am guessing it's the /a0M/e but not sure. I verified that the field id 00N600...for Opportunity.Account is correct.
 
Code:
/a0M/e—retURL=%2F{!Project_x__c.Id}&cancelURL=%2F{!Opportunity.Id}&CF00N60000001d9kB={!Opportunity.Account}

Any ideas of why the insufficient privileges and what the /a0M/e could represent?
 
Thanks.

Hello,
We are looking for someone to help us create a solution so that customers can fill out a form on the customer portal dependant on the type of issue they are having. These fields will be open text and need to change based on selected issue. 

For more details if you think you have the solution for us please respond.

Thank you,

Mark Brown.
Verisign Inc.

Hi,
 
How can we deploy custom page layouts from sandbox to production?

Also how can we deploy custom fields from Standard objects like Accounts from Sandbox to Production? I tried from Eclipse force.com IDE, but could not find the Account object XML.
 
Thanks for all your feedbacks.
Regards,
Ambili
  • May 09, 2008
  • Like
  • 0
Hi Everyone, I am working on an onClick Javascript button within the list view in salesforce.com.  And I got the script below to work when the field "Add_to_Call_List__c" is a text field, however when it is a picklist type, I need to use the ISPICKVAL or CASE function.  The business need is to update this field on mass when this button is clicked on within the list view.
 
Would anyone know what changes I need to make to:
 
"callList.Add_to_Call_List__c = "TRUE";"
 
when I make the field type a picklist?  As this field is going to be a picklist field type at the end of the day.  Let me know if more detail is required.
 
Thanks in advance!
Steve
 
====================================
 
// Include and initialize the AJAX Toolkit javascript library
//
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
// Get the list of job applications that should be closed by using the
// $ObjectType merge field to indicate the type of record Ids that
// are expected.
//
var leadID = {!GetRecordIds($ObjectType.Lead)};
if (leadID == null || leadID.length == 0) {
alert("You need to select Leads to add to the call list.");
} else {
var leadUpdate = new Array();
for (var i = 0; i < leadID.length; i++) {
var callList = new sforce.SObject("Lead");
//
// Since we'll be using the update call, we must set the id
// on the new job application record.
//
callList.Id = leadID[i];
//
callList.Add_to_Call_List__c = "TRUE";
// Finally add the record to our array.
//
leadUpdate.push(callList);
}
// Now make the update API call in a try statement so we can
// catch any errors. Save the resulting array so we can also
// check for problems with individual records.
//
var callCompleted = false;
try {
var result = sforce.connection.update(leadUpdate);
callCompleted = true;
} catch(error) {
alert("Failed to update Field with error: " + error);
}
// Now check for problems with individual records.
//
if (callCompleted) {
for (var i = 0; i < result.length; i++) {
if (!result[i].getBoolean("success")) {
alert("Job Application (id='" + leadID[i] +
"') could not be updated with error: " +
result[i].errors);
}
}
// Finally, refresh the browser to provide confirmation
// to the user that the job applications were rejected.
//
window.location.reload(true);
}
}
Has anyone successfully set up an unsubscribe/opt-out application or know how to do this within salesforce for emails?
Also opt-in ability would be helpful too. How do I then link it into the actual email?

I tried to install Unsubscribe opt-out 1.0.2 by Salesforce Labs. It looked like the perfect application to provide opt-out ability for an email campaign.

I received the following errors that I don't know how to fix.
Problem:
unsubscribe.testUnsubscribe2();

Item:
Apex

Problem:
unsubscribe.testUnsubscribe()  
Item: Class(01p30000000CfA9)   

Detail:

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Salutation__c]: [Salutation__c]
Class.unsubscribe.testUnsubscribe2: line 141, column 4;
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Salutation__c]: [Salutation__c]
Class.unsubscribe.testUnsubscribe: line 110, column 4

  • April 23, 2008
  • Like
  • 0
I had a bit of fun building an S-Control using AJAX that shows Contacts with similar email addresses.

I've posted the code on the wiki if anyone is interested. Feedback/suggestions welcome.

John Rotenstein
Sydney, Australia
I need a little help.  Can any one provide a custom formula that would give me a "rolling 12 month" annual revenue for and account.  Thank you.