• pacstrats
  • NEWBIE
  • 5 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies

Help!

 

I created the following VF pages along with the custom controller based on the example from the SFDC cookbook (almost word for word) but I have no idea how to promote to production since I have no idea how to write the unit test to validate the coverage (only at 51%).  Any help would be appreciated.

 

Page 1 of 3

<apex:page controller="newDonationController"tabStyle="Opportunity">

<apex:sectionHeader title="NewCustomerOpportunity"subtitle="Step1of3"/>

<apex:form >

<apex:pageBlock title="CustomerInformation">

<apex:facet name="footer">

<apex:commandButton action="{!step2}"value="Next"styleClass="btn"/>

</apex:facet>

 

<apex:pageBlockSection title="AccountInformation">

<apex:panelGrid columns="2">

<apex:outputLabel value="Account Name"for="accountName"/>

<apex:inputField id="accountName"value="{!account.name}"/>

</apex:panelGrid>

</apex:pageBlockSection>

 

<apex:pageBlockSection title="ContactInformation">

<apex:panelGrid columns="2">

<apex:outputLabel value="First Name"for="contactFirstName"/>

<apex:inputField id="contactFirstName"value="{!contact.firstName}"/>

<apex:outputLabel value="Last Name"for="contactLastName"/>

<apex:inputField id="contactLastName"value="{!contact.lastName}"/>

<apex:outputLabel value="Phone"for="contactPhone"/>

<apex:inputField id="contactPhone"value="{!contact.phone}"/>

<apex:outputLabel value="Email"for="contactEmail"/>

<apex:inputField id="contactEmail"value="{!contact.email}"/>

</apex:panelGrid>

</apex:pageBlockSection>

 

</apex:pageBlock>

</apex:form>

</apex:page>

Page 2 of 3

<apex:page controller="newDonationController"

tabStyle="Opportunity">

<apex:sectionHeader title="NewCustomerOpportunity"

subtitle="Step2of3"/>

<apex:form>

<apex:pageBlock title="Donation Information">

<apex:facet name="footer">

<apex:outputPanel>

<apex:commandButton action="{!step1}" value="Previous"

styleClass="btn"/>

<apex:commandButton action="{!step3}" value="Next"

styleClass="btn"/>

</apex:outputPanel>

</apex:facet>

 

<apex:pageBlockSection title="Donation Information">

<apex:panelGrid columns="2">

<apex:outputLabel value="Donation Name"

for="opportunityName"/>

<apex:inputField id="opportunityName"

value="{!opportunity.name}"/>

<apex:outputLabel value="Amount"

for="opportunityAmount"/>

<apex:inputField id="opportunityAmount"

value="{!opportunity.amount}"/>

<apex:outputLabel value="Close Date"

for="opportunityCloseDate"/>

<apex:inputField id="opportunityCloseDate"

value="{!opportunity.closeDate}"/>

<apex:outputLabel value="Type"

for="opportunityType"/>

<apex:inputField id="opportunityType"

value="{!opportunity.type}"/>

<apex:outputLabel value="Stage"

for="opportunityStageName"/>

<apex:inputField id="opportunityStageName"

value="{!opportunity.stageName}"/>

<apex:outputLabel value="Payment Type"

for="opportunityPaymentType"/>

<apex:inputField id="opportunityPaymentType"

value="{!opportunity.NFG__Payment_Type__c}"/>

<apex:outputLabel value="Check Date"

for="opportunityCheckDate"/>

<apex:inputField id="opportunityCheckDate"

value="{!opportunity.Check_Date__c}"/>

<apex:outputLabel value="Check #"

for="opportunityCheckNo"/>

<apex:inputField id="opportunityCheckNo"

value="{!opportunity.Check_Number__c}"/>

<apex:outputLabel value="Deposit Date"

for="opportunityDepositDate"/>

<apex:inputField id="opportunityDepositDate"

value="{!opportunity.Bank_Deposit_Date__c}"/>

<apex:outputLabel value="Primary Campaign"

for="opportunityCampaign"/>

<apex:inputField id="opportunityCampaign"

value="{!opportunity.CampaignId}"/>

<apex:outputLabel value="Internet Source"

for="opportunityInternetSource"/>

<apex:inputField id="opportunityInternetSource"

value="{!opportunity.NFG__Internet_Donation_Source__c}"/>

<apex:outputLabel value="Program Desingation"

for="opportunityProgram"/>

<apex:inputField id="opportunityProgram"

value="{!opportunity.Program_Designation__c}"/>

<apex:outputLabel value="Contact Role: {!contact.firstName} {!contact.lastName}"

for="contactRole"/><apex:inputField id="contactRole"

value="{!role.role}"/>

</apex:panelGrid>

</apex:pageBlockSection>

 

</apex:pageBlock>

</apex:form>

</apex:page>

Page 3 of 3

<apex:page controller="newDonationController"

tabStyle="Opportunity">

<apex:sectionHeader title="NewCustomerOpportunity"

subtitle="Step3of3"/>

<apex:form>

<apex:pageBlock title="Confirmation">

<apex:facet name="footer">

<apex:outputPanel >

<apex:commandButton action="{!step2}"

value="Previous"styleClass="btn"/>

<apex:commandButton action="{!save}"

value="Save"styleClass="btn"/>

</apex:outputPanel>

</apex:facet>

 

<apex:pageBlockSection title="Account Information">

<apex:panelGrid columns="2">

<apex:outputText value="Account Name:"/>

<apex:outputText value="{!account.name}"/>

</apex:panelGrid>

</apex:pageBlockSection>

 

<apex:pageBlockSection title="Contact Information">

<apex:panelGrid columns="2">

<apex:outputText value="First Name:"/>

<apex:outputText value="{!contact.firstName}"/>

<apex:outputText value="Last Name:"/>

<apex:outputText value="{!contact.lastName}"/>

<apex:outputText value="Phone:"/>

<apex:outputText value="{!contact.phone}"/>

<apex:outputText value="Email:"/>

<apex:outputText value="{!contact.email}"/>

<apex:outputText value="Role"/>

<apex:outputText value="{!role.role}"/>

</apex:panelGrid>

</apex:pageBlockSection>

 

<apex:pageBlockSection title="Donation Information">

<apex:panelGrid columns="2">

<apex:outputText value="Donation Name:"/>

<apex:outputText value="{!opportunity.name}"/>

<apex:outputText value="Amount:"/>

<apex:outputText value="{!opportunity.amount}"/>

<apex:outputText value="Type:"/>

<apex:outputText value="{!opportunity.type}"/>

<apex:outputText value="Close Date:"/>

<apex:outputText value="{!opportunity.closeDate}"/>

<apex:outputText value="Stage:"/>

<apex:outputText value="{!opportunity.stagename}"/>

<apex:outputText value="Payment Type:"/>

<apex:outputText value="{!opportunity.NFG__Payment_Type__c}"/>

<apex:outputText value="Check Date:"/>

<apex:outputText value="{!opportunity.Check_Date__c}"/>

<apex:outputText value="Check #:"/>

<apex:outputText value="{!opportunity.Check_Number__c}"/>

<apex:outputText value="Check Deposit Date:"/>

<apex:outputText value="{!opportunity.Bank_Deposit_Date__c}"/>

<apex:outputText value="Primary Campaign:"/>

<apex:outputText value="{!opportunity.campaignid}"/>

<apex:outputText value="Internet Source:"/>

<apex:outputText value="{!opportunity.NFG__Internet_Donation_Source__c}"/>

<apex:outputText value="Program Designation:"/>

<apex:outputText value="{!opportunity.Program_Designation__c}"/>

</apex:panelGrid>

</apex:pageBlockSection>

 

</apex:pageBlock>

</apex:form>

</apex:page>

public class newDonationController {

Account account;

Contact contact;

Opportunity opportunity;

OpportunityContactRole role;

Campaign campaign;

 

public Account getAccount() {

if(account == null)

return account;

}

public Contact getContact() {

if(contact == null) contact = new Contact();

return contact;

}

public Opportunity getOpportunity() {

if(opportunity == null) opportunity = new Opportunity();

return opportunity;

}

public OpportunityContactRole getRole() {

if(role == null) role = new OpportunityContactRole();

return role;

}

public PageReference step1() {

return Page.DonationStep1;

}

public PageReference step2() {

return Page.DonationStep2;

}

public PageReference step3() {

return Page.DonationStep3;

}

public PageReference save() {

account.phone = contact.phone;

account.NFG__Email__c = contact.email;

insert account;

 

contact.accountId = account.id;

insert contact;

 

opportunity.accountId = account.id;

insert opportunity;

 

role.opportunityId = opportunity.id;

role.contactId = contact.id;

insert role;

 

PageReference donationPage = new PageReference('/' + opportunity.id);

donationPage.setRedirect(true);return donationPage;

}

}

 

Message Edited by pacstrats on 03-30-2010 05:31 PM
I'm fairly new to Visualforce but a long-time user of SFDC. I am trying to create a simple wizard to walk users through 5 pages of one form instead of one long form per the usual SFDC UI. I am running into a major issue:

I have a number of validations set-up and beyond requiring certain fields, I have no idea how to prevent the user from continuing to the next page if there are validation issues. This is an issue since the whole process crashes if the user saves the record without fixing the issues.

I tried to copy as much from the example in the Cookbook but I've hit a wall.

Here is my code (substitute x for < due to posting issues):

Page 1 of 5 (all of the VF pages use the same logic/framework)

xapex: page standardController="Penrose_Project__c" extensions="PenroseProjectWizard" tabStyle="Penrose_Project__c">
xapex:sectionHeader title="New Project"
subtitle="Location - Step 1 of 5"/>
xapex:form >
xapex: pageBlock >

xapex: pageBlockButtons >
xapex:commandButton action="{!cancel}" value="Cancel"/>
xapex:commandButton action="{!step2}" value="Next"/>
x/apex: pageBlockButtons>

xapex: pageBlockSection columns="2" title="Location Information">
xapex: outputField value="{!PenProj.Name}"/>
x/br>
xapex:inputField id="building" value="{!PenProj.P_Building__c}" required="TRUE"/>
x/br>
xapex:inputField id="floor" value="{!PenProj.P_Floor__c}" required="TRUE"/>
x/apex: pageBlockSection>

xapex: pageBlockSection columns="2" title="Departments Affected">
xapex:inputField id="above" value="{!PenProj.Above__c}" required="TRUE"/ style="width:300px">
xapex:inputField id="below" value="{!PenProj.Below__c}" required="TRUE"/ style="width:300px">
xapex:inputField id="north" value="{!PenProj.North__c}" required="TRUE"/ style="width:300px">
xapex:inputField id="south" value="{!PenProj.South__c}" required="TRUE"/ style="width:300px">
xapex:inputField id="east" value="{!PenProj.East__c}" required="TRUE"/ style="width:300px">
xapex:inputField id="west" value="{!PenProj.West__c}" required="TRUE"/ style="width:300px">
x/apex: pageBlockSection>

xapex: pageBlockSection columns="2" title="Project Dates">
xapex:inputField id="start" value="{!PenProj.Project_Start_Date__c}" required="TRUE"/>
xapex:inputField id="end" value="{!PenProj.Project_End_Date__c}" required="TRUE"/>
x/apex: pageBlockSection>

x/apex: pageBlock>
x/apex:form>
x/apex: page>

Controller:

public class PenroseProjectWizard {

Account account;
Penrose_Project__c PenProj;

public Penrose_Project__c getPenProj(){
if(PenProj == null) PenProj = new Penrose_Project__c();
return PenProj;
}

public PenroseProjectWizard(ApexPages.StandardController stdController){
PenProj = (Penrose_Project__c) stdController.getRecord();
PenProj.Location__c = ApexPages.currentPage().getParameters().get('location');
PenProj.Name = ApexPages.currentPage().getParameters().get('name');
PenProj.RecordTypeId = [SELECT r.Id FROM RecordType r WHERE r.SobjectType = 'Penrose_Project__c' AND r.Name = :ApexPages.currentPage().getParameters().get('recordtype')].Id;
}

public PageReference cancel() {
PageReference Cancelled = new PageReference('/' + PenProj.Location__c);
Cancelled.setRedirect(true);
return Cancelled;
}
public PageReference step1() {
return Page.newphproject1;
}
public PageReference step2() {
return Page.newphproject2;
}
public PageReference step3() {
return Page.newphproject3;
}
public PageReference step4() {
return Page.newphproject4;
}
public PageReference step5() {
return Page.newphproject5;
}
public PageReference save() {
insert PenProj;

PageReference ProjectStep = new PageReference('/' + PenProj.id);
ProjectStep.setRedirect(true);
return ProjectStep;
}
}

Custom Button:

https://na6.salesforce.com/apex/newphproject1?
location={!Account.Id}&
name="Pending"&
recordtype={!Account.RecordType}

Any help, tips or tricks would be greatly appreciated.

Travis

Message Edited by pacstrats on 11-14-2008 12:49 AM

Message Edited by pacstrats on 11-14-2008 12:49 AM

Message Edited by pacstrats on 11-14-2008 12:50 AM

Message Edited by pacstrats on 11-14-2008 12:54 AM

Message Edited by pacstrats on 11-14-2008 12:56 AM
I'm somewhat familiar with Triggers but I'm having a hard time with this one, and I'm not even sure it can be done.

Since I can't use workflows to automatically update a lookup field, I want to create a Trigger to update the lookup field of a standard object (Lead) with the ID/Name of a custom object (Employee) based on the value of a custom field within the Lead object.

In short, my Employee object is related to Leads and I'd like the trigger to use the value of the custom field (EmployeeName__c) in Lead to query the Name field in the Employee custom object to retrieve and store the ID of the Employee record in the lookup field within Leads called Employee__c.

Any thoughts?

T
I'm fairly new to Visualforce but a long-time user of SFDC. I am trying to create a simple wizard to walk users through 5 pages of one form instead of one long form per the usual SFDC UI. I am running into a major issue:

I have a number of validations set-up and beyond requiring certain fields, I have no idea how to prevent the user from continuing to the next page if there are validation issues. This is an issue since the whole process crashes if the user saves the record without fixing the issues.

I tried to copy as much from the example in the Cookbook but I've hit a wall.

Here is my code (substitute x for < due to posting issues):

Page 1 of 5 (all of the VF pages use the same logic/framework)

xapex: page standardController="Penrose_Project__c" extensions="PenroseProjectWizard" tabStyle="Penrose_Project__c">
xapex:sectionHeader title="New Project"
subtitle="Location - Step 1 of 5"/>
xapex:form >
xapex: pageBlock >

xapex: pageBlockButtons >
xapex:commandButton action="{!cancel}" value="Cancel"/>
xapex:commandButton action="{!step2}" value="Next"/>
x/apex: pageBlockButtons>

xapex: pageBlockSection columns="2" title="Location Information">
xapex: outputField value="{!PenProj.Name}"/>
x/br>
xapex:inputField id="building" value="{!PenProj.P_Building__c}" required="TRUE"/>
x/br>
xapex:inputField id="floor" value="{!PenProj.P_Floor__c}" required="TRUE"/>
x/apex: pageBlockSection>

xapex: pageBlockSection columns="2" title="Departments Affected">
xapex:inputField id="above" value="{!PenProj.Above__c}" required="TRUE"/ style="width:300px">
xapex:inputField id="below" value="{!PenProj.Below__c}" required="TRUE"/ style="width:300px">
xapex:inputField id="north" value="{!PenProj.North__c}" required="TRUE"/ style="width:300px">
xapex:inputField id="south" value="{!PenProj.South__c}" required="TRUE"/ style="width:300px">
xapex:inputField id="east" value="{!PenProj.East__c}" required="TRUE"/ style="width:300px">
xapex:inputField id="west" value="{!PenProj.West__c}" required="TRUE"/ style="width:300px">
x/apex: pageBlockSection>

xapex: pageBlockSection columns="2" title="Project Dates">
xapex:inputField id="start" value="{!PenProj.Project_Start_Date__c}" required="TRUE"/>
xapex:inputField id="end" value="{!PenProj.Project_End_Date__c}" required="TRUE"/>
x/apex: pageBlockSection>

x/apex: pageBlock>
x/apex:form>
x/apex: page>

Controller:

public class PenroseProjectWizard {

Account account;
Penrose_Project__c PenProj;

public Penrose_Project__c getPenProj(){
if(PenProj == null) PenProj = new Penrose_Project__c();
return PenProj;
}

public PenroseProjectWizard(ApexPages.StandardController stdController){
PenProj = (Penrose_Project__c) stdController.getRecord();
PenProj.Location__c = ApexPages.currentPage().getParameters().get('location');
PenProj.Name = ApexPages.currentPage().getParameters().get('name');
PenProj.RecordTypeId = [SELECT r.Id FROM RecordType r WHERE r.SobjectType = 'Penrose_Project__c' AND r.Name = :ApexPages.currentPage().getParameters().get('recordtype')].Id;
}

public PageReference cancel() {
PageReference Cancelled = new PageReference('/' + PenProj.Location__c);
Cancelled.setRedirect(true);
return Cancelled;
}
public PageReference step1() {
return Page.newphproject1;
}
public PageReference step2() {
return Page.newphproject2;
}
public PageReference step3() {
return Page.newphproject3;
}
public PageReference step4() {
return Page.newphproject4;
}
public PageReference step5() {
return Page.newphproject5;
}
public PageReference save() {
insert PenProj;

PageReference ProjectStep = new PageReference('/' + PenProj.id);
ProjectStep.setRedirect(true);
return ProjectStep;
}
}

Custom Button:

https://na6.salesforce.com/apex/newphproject1?
location={!Account.Id}&
name="Pending"&
recordtype={!Account.RecordType}

Any help, tips or tricks would be greatly appreciated.

Travis

Message Edited by pacstrats on 11-14-2008 12:49 AM

Message Edited by pacstrats on 11-14-2008 12:49 AM

Message Edited by pacstrats on 11-14-2008 12:50 AM

Message Edited by pacstrats on 11-14-2008 12:54 AM

Message Edited by pacstrats on 11-14-2008 12:56 AM
I'm somewhat familiar with Triggers but I'm having a hard time with this one, and I'm not even sure it can be done.

Since I can't use workflows to automatically update a lookup field, I want to create a Trigger to update the lookup field of a standard object (Lead) with the ID/Name of a custom object (Employee) based on the value of a custom field within the Lead object.

In short, my Employee object is related to Leads and I'd like the trigger to use the value of the custom field (EmployeeName__c) in Lead to query the Name field in the Employee custom object to retrieve and store the ID of the Employee record in the lookup field within Leads called Employee__c.

Any thoughts?

T
I have created an object (table) with three fields -- number, name, and person.  There are only five records in this object each with a unique "number" (1 - 5).
 
On the account view, I have placed a picklist with the numbers 1 through 5 to match the "number" field in the custom object. 
 
My goal is to place two more fields on the account view such that, when the user selects a pick list value, the other two fields will be filled in with the corresponding "name" and "person" fields from the custom object.
 
Any help will be appreciated -- or the location of docs.
 
TIA