-
ChatterFeed
-
1Best Answers
-
0Likes Received
-
0Likes Given
-
17Questions
-
49Replies
Salesforce object: columns to rows
Hello,
How would one convert the data in an object in the following way:
From this:
Object A: 1 record
ContactId,Phone,MobilePhone,HomePhone
a000axb03423xbg,222-222-2222,111-111-1111,000-000-0000
To this:
Object B: 3 records
ContactId,PhoneToCall
a000axb03423xbg,222-222-2222
a000axb03423xbg,111-111-1111
a000axb03423xbg,000-000-0000
This is a data conversion that I'd have to be able to schedule out of SF on a nightly basis.
This could be accomplished in SQL pretty easily or if I could replicate my force data down into a SQL database, but I'm not finding a way to do it in SOQL. Any suggestions?
-
- jordanm
- August 19, 2013
- Like
- 0
- Continue reading or reply
Required drop down lists
-
- jordanm
- July 24, 2012
- Like
- 0
- Continue reading or reply
Change look/feel of Visual Flows with Visualforce page?
The '12 summer release notes state that you can now alter the layout, look, and feel of flows with visualforce page/css etc.
Is there any documentation on how to accomplish this?
-
- jordanm
- May 14, 2012
- Like
- 0
- Continue reading or reply
changing the flow UI with visualforce?
The '12 summer release notes state that you can alter the look and feel of flows with visualforce page/css etc.
Is there any documentation on how to accomplish this?
-
- jordanm
- May 12, 2012
- Like
- 0
- Continue reading or reply
After update several hours ago renderAs PDF doesn't seem to be working?
It won't even work for the canned quote2PDF example in the cookbook...
I get this error message on an otherwise blank failure page: "PDF generation failed. Check the page markup is valid. "
Anyone else seeing this?
-
- jordanm
- May 12, 2012
- Like
- 0
- Continue reading or reply
Help with Loop Construction
Hi,
I need a hand building this loop for the following scenario. I have a grandparent that is passed to a page via query string, this grandparent refers to multiple parents, and those multiple parents each have multiple children
I want to yield this:
grandparent 1
+++parent 1
++++++child a
++++++child b
+++parent 2
++++++child c
++++++child d
The loop in the controller is confounding me.
parents = [SELECT id,Name FROM Parent__c WHERE Grandparent__c=:grandparentId]; for(Parent__c parents1:parents) { // fetch the values by SOQL on the basis of parent id children=[select id,Name FROM Child__c WHERE Parent__c=:parents1.id]; system.debug('size'+ parents.size()); system.debug('>>>>>>>>>>>>>>>>>'); children1.addall(children); }
This is clearly incorrect. It is going to build a list of ALL the parents of the grandparent and then take ALL of their children and store them in children1 variable. This won't accomplish the tree-type view I want, it will instead show this:
grandparent 1
+++parent 1
++++++child a
++++++child b
++++++child c
++++++child d
+++parent 2
++++++child a
++++++child b
++++++child c
++++++child d
How should I build this loop?
-
- jordanm
- May 10, 2012
- Like
- 0
- Continue reading or reply
Check if querystring parameter is null
Hello, I have this URL with 4 parameters passed in it. If the 4th family parameter is empty I want to redirect to an error page (or handle it some other way)
This is my url that should error out:
"/apex/osmStep1?id=a00Z00000012XJl&asmt=Outcome%20Scale%20Matrix&version=2.0&fam="
fam= at the end is empty
this is my controller code block:
private final Participant__c participant; private final Assessment__c assessment; private final Family__c family; public Participant__c getParticipant() { return participant; } public Assessment__c getAssessment() { return assessment; } public Family__c getFamily() { return family; } public osmController() { participant = [select id, Name, Family__c from Participant__c where id = :ApexPages.currentPage().getParameters().get('id')]; assessment = [select id, Name from Assessment__c where Name = :ApexPages.currentPage().getParameters().get('asmt') AND Version__c = :ApexPages.currentPage().getParameters().get('version')]; if (null != ApexPages.currentPage().getParameters().get('fam')) { family = [select id, Name, Poverty_Level_2012__c from Family__c where Name = :ApexPages.currentPage().getParameters().get('fam')]; } else { PageReference p = null; p = Page.failure; p.getParameters().put('error','noFamily'); p.setRedirect(true); } }
This basically takes me into the page even when the fam parameter is empty. What am I doing wrong?
-
- jordanm
- May 08, 2012
- Like
- 0
- Continue reading or reply
Page & custom controller extension: Second child level yields unwanted results
Hello,
I've been working on this PDF page that involves a Grandparent (family object) --> Parent (participant object) --> Child (participant incomes object) relationship.
I finally got a custom controller extension figured out which allows me to go down two child levels (which is illegal using just the standard force.com controller)
but I'm doing something wrong. My family yields all the participants in it just fine, but when I go to pull the participant's income information it is printing all the incomes for all the participants in the family instead of the income only related specifically to each participant.
What am I doing wrong?
Here is the page:
<apex:page standardController="Family__c" showHeader="false" renderAs="pdf" extensions="UIApplicationEXT"> <body> <apex:stylesheet value="{!URLFOR($Resource.CRTpdf, 'styles.css')}"/> <apex:image value="{!URLFOR($Resource.CRTpdf, 'logo.gif')}"/> <apex:panelGrid columns="1" styleClass="companyTable" width="100%"> <apex:outputText value="{!$Organization.Name}" styleClass="companyName"/> <apex:outputText value="{!$Organization.Street}"/> <apex:outputText value="{!$Organization.City}, {!$Organization.State} {!$Organization.PostalCode}"/> <apex:outputText value="{!$Organization.Phone}"/> </apex:panelGrid> <apex:outputPanel layout="block" styleClass="line"/> <apex:panelGrid columns="1" styleClass="centered" width="100%"> <apex:panelGrid columns="2" width="100%" cellpadding="0" cellspacing="0" columnClasses="left,right"> <apex:outputText value="Family# {!Family__c.name}" styleClass="customerName"/> <apex:outputField value="{!Family__c.lastmodifieddate}" style="text-align:right"/> <apex:outputText value="Total Family Income: "/> <apex:outputField value="{!Family__c.Family_Income__c}"/> <apex:outputText value="Family Size: "/> <apex:outputField value="{!Family__c.Family_Size__c}"/> <apex:outputText value="Family Type: "/> <apex:outputField value="{!Family__c.Family_Type__c}"/> </apex:panelGrid> </apex:panelGrid> <apex:repeat value="{!Family__c.Family_Households__r}" var="fhh"> <apex:outputPanel layout="block" styleClass="lineSmall"/> <apex:outputText value="Address Type: {!fhh.Address__r.Address_Type__c}"/> <apex:panelGrid columns="1" styleClass="centered" width="100%"> <apex:outputText value="{!fhh.Address__r.Address_1__c} {!fhh.Address__r.Address_2__c}"/> <apex:outputText value="{!fhh.Address__r.City__c}, {!fhh.Address__r.State__c} {!fhh.Address__r.Zip__c}"/> </apex:panelGrid> </apex:repeat> <apex:outputPanel layout="block" styleClass="lineSmall"/> <apex:repeat value="{!parts}" var="mem"> <apex:panelGrid columns="2" columnClasses="left,right" width="100%"> <apex:panelGroup > <apex:outputText value="{!mem.First_Name__c} {!mem.Middle_Name__c} {!mem.Last_Name__c}" styleClass="productName"/> <apex:outputPanel layout="block" styleClass="productDetail"> <apex:repeat value="{!partIncomes1}" var="inc"> <apex:panelGrid columns="2" columnClasses="left,none"> <apex:outputText value="Income Type: " style="font-weight:bold"/> <apex:outputField value="{!inc.Income_Type__c}"/> <apex:outputText value="Annual Income: " style="font-weight:bold"/> <apex:outputField value="{!inc.Annual_Calculation__c}"/> </apex:panelGrid> </apex:repeat> <apex:panelGrid columns="2" columnClasses="left,none"> <apex:outputText value="Social Security Number:" style="font-weight:bold"/> <apex:outputField value="{!mem.Social_Security_Number__c}"/> <apex:outputText value="Gender:" style="font-weight:bold"/> <apex:outputField value="{!mem.Gender__c}"/> </apex:panelGrid> </apex:outputPanel> </apex:panelGroup> <apex:panelGrid columns="2"> <apex:outputText value="Total Income: "/> <apex:outputField value="{!mem.Total_Income__c}" styleClass="productName"/> </apex:panelGrid> </apex:panelGrid> </apex:repeat> <apex:outputPanel layout="block" styleClass="line"/> </body> </apex:page>
Here is the custom controller extension:
public class UIApplicationEXT{ public Family__c fam {get;set;} public id famId {get;set;} public list<Participant__c> parts {get;set;} public list<Participant_Income__c> partIncomes1 {get;set;} public UIApplicationEXT(ApexPages.StandardController controller) { fam = new Family__c(); parts = new list<Participant__c>(); list<Participant_Income__c> partIncomes = new list<Participant_Income__c>(); partIncomes1 = new list<Participant_Income__c>(); famId=system.currentpagereference().getparameters().get('id'); // fetch the values by SOQL on the basis of family id parts = [SELECT id,Name,First_Name__c, Last_Name__c, Middle_Name__c, Gender__c, Total_Income__c, Social_Security_Number__c FROM Participant__c WHERE Family__c=:famId]; for(Participant__c parts1:parts) { // fetch the values by SOQL on the basis of participant id partIncomes=[select id,Name,Income_Type__c, Annual_Calculation__c FROM Participant_Income__c WHERE Participant__c=:parts1.id]; partIncomes1.addall(partIncomes); } } }
Any ideas?
-
- jordanm
- May 04, 2012
- Like
- 0
- Continue reading or reply
Controller Extension that moves down through 2 children
Hello,
I am getting this error:
Save error: Object type not accessible. Please check permissions and make sure the object is not in development mode: SOQL statements cannot query aggregate relationships more than 1 level away from the root entity object
I basically have a family object, which can have multiple participant objects in it, and each of those participants have a specific relationship within the family. I have a junction object called Family Relationship that is a child to both Family and Participant objects
Here is my page/code:
<apex:page standardController="Family__c" showHeader="false" renderAs="pdf"> <body> <apex:stylesheet value="{!URLFOR($Resource.pdfresource, 'styles.css')}"/> <apex:image value="{!URLFOR($Resource.pdfresource, 'logo.gif')}"/> <apex:panelGrid columns="1" styleClass="companyTable" width="100%"> <apex:outputText value="{!$Organization.Name}" styleClass="companyName"/> <apex:outputText value="{!$Organization.Street}"/> <apex:outputText value="{!$Organization.City}, {!$Organization.State} {!$Organization.PostalCode}"/> <apex:outputText value="{!$Organization.Phone}"/> </apex:panelGrid> <apex:outputPanel layout="block" styleClass="line"/> <apex:panelGrid columns="1" styleClass="centered" width="100%"> <apex:panelGrid columns="2" width="100%" cellpadding="0" cellspacing="0" columnClasses="left,right"> <apex:outputText value="Family# {!Family__c.name}" styleClass="customerName"/> <apex:outputField value="{!Family__c.lastmodifieddate}" style="text-align:right"/> <apex:outputText value="Total Family Income: "/> <apex:outputField value="{!Family__c.Family_Income__c}"/> <apex:outputText value="Family Size: "/> <apex:outputField value="{!Family__c.Family_Size__c}"/> <apex:outputText value="Family Type: "/> <apex:outputField value="{!Family__c.Family_Type__c}"/> </apex:panelGrid> </apex:panelGrid> <apex:repeat value="{!Family__c.Family_Households__r}" var="fhh"> <apex:outputPanel layout="block" styleClass="lineSmall"/> <apex:outputText value="Address Type: {!fhh.Address__r.Address_Type__c}"/> <apex:panelGrid columns="1" styleClass="centered" width="100%"> <apex:outputText value="{!fhh.Address__r.Address_1__c} {!fhh.Address__r.Address_2__c}"/> <apex:outputText value="{!fhh.Address__r.City__c}, {!fhh.Address__r.State__c} {!fhh.Address__r.Zip__c}"/> </apex:panelGrid> </apex:repeat> <apex:outputPanel layout="block" styleClass="lineSmall"/> <apex:repeat value="{!Family__c.Family_Members__r}" var="mem"> <apex:panelGrid columns="2" columnClasses="left,right" width="100%"> <apex:panelGroup > <apex:outputText value="{!mem.First_Name__c} {!mem.Middle_Name__c} {!mem.Last_Name__c}" styleClass="productName"/> <apex:outputPanel layout="block" styleClass="productDetail"> <apex:panelGrid columns="2" columnClasses="left,none"> <apex:repeat value="{!mem.FamilyRel__r}" var="rel"> <apex:outputText value="Relationship: " style="font-weight:bold"/> <apex:outputField value="{!rel.Relationship__c}"/> </apex:repeat> <apex:outputText value="Social Security Number:" style="font-weight:bold"/> <apex:outputField value="{!mem.Social_Security_Number__c}"/> <apex:outputText value="Gender:" style="font-weight:bold"/> <apex:outputField value="{!mem.Gender__c}"/> </apex:panelGrid> </apex:outputPanel> </apex:panelGroup> <apex:outputField value="{!mem.Total_Income__c}" styleClass="productName"/> </apex:panelGrid> </apex:repeat> <apex:outputPanel layout="block" styleClass="line"/> </body> </apex:page>
this code block, specifically, creates the error, because I'm trying to move from family to participant (1 level) and then an additional level to the relationship junction object.
<apex:repeat value="{!mem.FamilyRel__r}" var="rel"> <apex:outputText value="Relationship: " style="font-weight:bold"/> <apex:outputField value="{!rel.Relationship__c}"/> </apex:repeat>
I know this is illegal. The question is how do I go about writing an extension to accomodate this case?
Any guidance would be appreciated, thank you!
-
- jordanm
- May 03, 2012
- Like
- 0
- Continue reading or reply
Test Case for passing parameters via button click
Hello,
I have a custom wizard controller that is working and am trying to write a test case for it. I have a button that writes three parameters to querystring in the url.
Controller
public class osmController { // These member variables maintain the state of the wizard. // When users enter data into the wizard, their input is stored // in these variables. Participant_Assessment__c pAsmt; Participant_Interaction__c pInt; Participant_Answer__c pAns1; ... private final Participant__c participant; private final Assessment__c assessment; private final Family__c family; string possibleanswer1 = null; ... // The next methods return one of each of the member // variables. If this is the first time the method is called, // it creates an empty record for the variable. public List<selectOption> getanswer1() { List<selectOption> options = new List<selectOption>(); //new list for holding all of the picklist options for (Possible_Answer__c pa1 : [SELECT Id, Answer_Display__c FROM Possible_Answer__c WHERE Dimension__c = 'Income']) { options.add(new selectOption(pa1.Id, pa1.Answer_Display__c)); //for all records found - add them to the picklist options } return options; //return the picklist options ... public List<selectOption> getInteractiontypes() { List<selectOption> options = new List<selectOption>(); //new list for holding all of the picklist options options.add(new selectOption('', '--None--')); //add the first option of '- None -' in case the user doesn't want to select a value or in case no values are returned from query below for (Interaction_Type__c Interactiontypes : [SELECT Id, Description__c FROM Interaction_Type__c WHERE IsDeleted = FALSE]) { options.add(new selectOption(Interactiontypes.Description__c, Interactiontypes.Description__c)); //for all records found - add them to the picklist options } return options; //return the picklist options } public Participant_Assessment__c getpAsmt() { if(pAsmt == null) pAsmt = new Participant_Assessment__c(); return pAsmt; } public Participant_Interaction__c getpInt() { if(pInt == null) pInt = new Participant_Interaction__c(); return pInt; } public Participant_Answer__c getpAns1() { if(pAns1 == null) pAns1 = new Participant_Answer__c(); return pAns1; } public Participant_Answer__c getpAns2() { if(pAns2 == null) pAns2 = new Participant_Answer__c(); return pAns2; } public Participant_Answer__c getpAns3() { if(pAns3 == null) pAns3 = new Participant_Answer__c(); return pAns3; } public Participant_Answer__c getpAns4() { if(pAns4 == null) pAns4 = new Participant_Answer__c(); return pAns4; } public Participant_Answer__c getpAns5() { if(pAns5 == null) pAns5 = new Participant_Answer__c(); return pAns5; } public Participant_Answer__c getpAns6() { if(pAns6 == null) pAns6 = new Participant_Answer__c(); return pAns6; } public Participant_Answer__c getpAns7() { if(pAns7 == null) pAns7 = new Participant_Answer__c(); return pAns7; } public Participant_Answer__c getpAns8() { if(pAns8 == null) pAns8 = new Participant_Answer__c(); return pAns8; } public Participant_Answer__c getpAns9() { if(pAns9 == null) pAns9 = new Participant_Answer__c(); return pAns9; } public Participant_Answer__c getpAns10() { if(pAns10 == null) pAns10 = new Participant_Answer__c(); return pAns10; } public Participant_Answer__c getpAns11() { if(pAns11 == null) pAns11 = new Participant_Answer__c(); return pAns11; } public Participant_Answer__c getpAns12() { if(pAns12 == null) pAns12 = new Participant_Answer__c(); return pAns12; } public Participant_Answer__c getpAns13() { if(pAns13 == null) pAns13 = new Participant_Answer__c(); return pAns13; } public Participant_Answer__c getpAns14() { if(pAns14 == null) pAns14 = new Participant_Answer__c(); return pAns14; } public Participant_Answer__c getpAns15() { if(pAns15 == null) pAns15 = new Participant_Answer__c(); return pAns15; } public Participant_Answer__c getpAns16() { if(pAns16 == null) pAns16 = new Participant_Answer__c(); return pAns16; } public Participant_Answer__c getpAns17() { if(pAns17 == null) pAns17 = new Participant_Answer__c(); return pAns17; } public Participant_Answer__c getpAns18() { if(pAns18 == null) pAns18 = new Participant_Answer__c(); return pAns18; } public Participant__c getParticipant() { return participant; } public Assessment__c getAssessment() { return assessment; } public Family__c getFamily() { return family; } public osmController() { if (ApexPages.currentPage().getParameters().get('family') == '') { //do nothing } else { participant = [select id, name from Participant__c where id = <================GETTING ERROR HERE :ApexPages.currentPage().getParameters().get('id')]; } assessment = [select id, name from Assessment__c where Name = :ApexPages.currentPage().getParameters().get('asmt') AND Version__c = :ApexPages.currentPage().getParameters().get('version')]; if (ApexPages.currentPage().getParameters().get('family') == '') { //do nothing } else { family = [select id, name, Poverty_Level_2012__c from Family__c where name = :ApexPages.currentPage().getParameters().get('family')]; } } public String getpossibleanswer1() { return possibleanswer1; } public String getpossibleanswer2() { return possibleanswer2; } public String getpossibleanswer3() { return possibleanswer3; } public String getpossibleanswer4() { return possibleanswer4; } public String getpossibleanswer5() { return possibleanswer5; } public String getpossibleanswer6() { return possibleanswer6; } public String getpossibleanswer7() { return possibleanswer7; } public String getpossibleanswer8() { return possibleanswer8; } public String getpossibleanswer9() { return possibleanswer9; } public String getpossibleanswer10() { return possibleanswer10; } public String getpossibleanswer11() { return possibleanswer11; } public String getpossibleanswer12() { return possibleanswer12; } public String getpossibleanswer13() { return possibleanswer13; } public String getpossibleanswer14() { return possibleanswer14; } public String getpossibleanswer15() { return possibleanswer15; } public String getpossibleanswer16() { return possibleanswer16; } public String getpossibleanswer17() { return possibleanswer17; } public String getpossibleanswer18() { return possibleanswer18; } public void setpossibleanswer1(String possibleanswer1) { this.possibleanswer1 = possibleanswer1; } public void setpossibleanswer2(String possibleanswer2) { this.possibleanswer2 = possibleanswer2; } public void setpossibleanswer3(String possibleanswer3) { this.possibleanswer3 = possibleanswer3; } public void setpossibleanswer4(String possibleanswer4) { this.possibleanswer4 = possibleanswer4; } public void setpossibleanswer5(String possibleanswer5) { this.possibleanswer5 = possibleanswer5; } public void setpossibleanswer6(String possibleanswer6) { this.possibleanswer6 = possibleanswer6; } public void setpossibleanswer7(String possibleanswer7) { this.possibleanswer7 = possibleanswer7; } public void setpossibleanswer8(String possibleanswer8) { this.possibleanswer8 = possibleanswer8; } public void setpossibleanswer9(String possibleanswer9) { this.possibleanswer9 = possibleanswer9; } public void setpossibleanswer10(String possibleanswer10) { this.possibleanswer10 = possibleanswer10; } public void setpossibleanswer11(String possibleanswer11) { this.possibleanswer11 = possibleanswer11; } public void setpossibleanswer12(String possibleanswer12) { this.possibleanswer12 = possibleanswer12; } public void setpossibleanswer13(String possibleanswer13) { this.possibleanswer13 = possibleanswer13; } public void setpossibleanswer14(String possibleanswer14) { this.possibleanswer14 = possibleanswer14; } public void setpossibleanswer15(String possibleanswer15) { this.possibleanswer15 = possibleanswer15; } public void setpossibleanswer16(String possibleanswer16) { this.possibleanswer16 = possibleanswer16; } public void setpossibleanswer17(String possibleanswer17) { this.possibleanswer17 = possibleanswer17; } public void setpossibleanswer18(String possibleanswer18) { this.possibleanswer18 = possibleanswer18; } // The next methods control navigation through // the wizard. Each returns a PageReference for one of the pages // in the wizard. Note that the redirect attribute does not need to // be set on the PageReference because the URL does not need to change // when users move from page to page. public PageReference step1() { return Page.osmStep1; } public PageReference step2() { return Page.osmStep2; } public PageReference step3() { return Page.osmStep3; } public PageReference step4() { return Page.osmStep4; } public PageReference step5() { return Page.osmStep5; } public PageReference step6() { return Page.osmStep6; } public PageReference step7() { return Page.osmStep7; } public PageReference step8() { return Page.osmStep8; } public PageReference step9() { return Page.osmStep9; } // This method cancels the wizard, and returns the user to the // Participants tab public PageReference cancel() { PageReference participantPage = new ApexPages.StandardController(participant).view(); participantPage.setRedirect(true); return participantPage; } // This method performs the final save for all objects, and // then navigates the user to the detail page for the new // participant assessment. public PageReference save() { PageReference p = null; if (this.family == null || this.participant == null || this.assessment == null) { p = Page.failure; p.getParameters().put('error','noParam'); } else { try { // Create the participant assessment. Before inserting, use the id field // from the active participant and assessment that are passed via custom button to create // the relationship between the participant and assessment and the participant assessment. pAsmt.Participant__c = participant.id; pAsmt.Assessment__c = assessment.id; insert pAsmt; // Create the participant answers. Before inserting, use the id field // that's created once the participant assessment is inserted to create // the relationship between the participant assessment and the participant answer. pAns1.Participant_Assessment__c = pAsmt.id; pAns1.Possible_Answer__c = possibleanswer1; insert pAns1; pAns2.Participant_Assessment__c = pAsmt.id; pAns2.Possible_Answer__c = possibleanswer2; insert pAns2; pAns3.Participant_Assessment__c = pAsmt.id; pAns3.Possible_Answer__c = possibleanswer3; insert pAns3; pAns4.Participant_Assessment__c = pAsmt.id; pAns4.Possible_Answer__c = possibleanswer4; insert pAns4; pAns5.Participant_Assessment__c = pAsmt.id; pAns5.Possible_Answer__c = possibleanswer5; insert pAns5; pAns6.Participant_Assessment__c = pAsmt.id; pAns6.Possible_Answer__c = possibleanswer6; insert pAns6; pAns7.Participant_Assessment__c = pAsmt.id; pAns7.Possible_Answer__c = possibleanswer7; insert pAns7; pAns8.Participant_Assessment__c = pAsmt.id; pAns8.Possible_Answer__c = possibleanswer8; insert pAns8; pAns9.Participant_Assessment__c = pAsmt.id; pAns9.Possible_Answer__c = possibleanswer9; insert pAns9; pAns10.Participant_Assessment__c = pAsmt.id; pAns10.Possible_Answer__c = possibleanswer10; insert pAns10; pAns11.Participant_Assessment__c = pAsmt.id; pAns11.Possible_Answer__c = possibleanswer11; insert pAns11; pAns12.Participant_Assessment__c = pAsmt.id; pAns12.Possible_Answer__c = possibleanswer12; insert pAns12; pAns13.Participant_Assessment__c = pAsmt.id; pAns13.Possible_Answer__c = possibleanswer13; insert pAns13; pAns14.Participant_Assessment__c = pAsmt.id; pAns14.Possible_Answer__c = possibleanswer14; insert pAns14; pAns15.Participant_Assessment__c = pAsmt.id; pAns15.Possible_Answer__c = possibleanswer15; insert pAns15; pAns16.Participant_Assessment__c = pAsmt.id; pAns16.Possible_Answer__c = possibleanswer16; insert pAns16; pAns17.Participant_Assessment__c = pAsmt.id; pAns17.Possible_Answer__c = possibleanswer17; insert pAns17; pAns18.Participant_Assessment__c = pAsmt.id; pAns18.Possible_Answer__c = possibleanswer18; insert pAns18; //create participant interaction for OSM completion pInt.Interaction_Date__c = pAsmt.Assessment_Date__c; pInt.Interaction_Summary__c = 'OSM Completed'; pInt.Participant__c = participant.id; insert pInt; } catch (Exception e) { p = Page.failure; p.getParameters().put('error','noInsert'); } } if (p == null) { p = new ApexPages.StandardController(pAsmt).view(); } p.setRedirect(true); return p; } }
The test method, which tells me the controller is hitting exception: "List has no rows for assignment to sObject" on line 307 which I marked in the above controller code...
@isTest public class TestosmController { public static testMethod void myUnitTest(){ PageReference pageRef1 = Page.osmStep1; Test.setCurrentPage(pageRef1); osmController controller = new osmController(); String savePage = controller.save().getUrl(); // verify that page fails without parameters System.assertEquals('/apex/failure?error=noParam', savePage); Profile pf = [Select Id from Profile where Name = 'Sys Admin']; User u = new User(); u.FirstName = 'Test'; u.LastName = 'User'; u.Email = 'testuser@test123456789.com'; u.CompanyName = 'test.com'; u.Title = 'Test User'; u.Username = 'testuser@test123456789.com'; u.Alias = 'testuser'; u.CommunityNickname = 'Test User'; u.TimeZoneSidKey = 'America/Mexico_City'; u.LocaleSidKey = 'en_US'; u.EmailEncodingKey = 'ISO-8859-1'; u.ProfileId = pf.Id; u.LanguageLocaleKey = 'en_US'; insert u; system.runAs(u){ Family__c o = new Family__c(); o.Family_Type__c = 'Other'; insert o; system.assertEquals(o.Family_Income__c, null); //Test payments on insert Participant__c p1 = new Participant__c(); p1.Family__c = o.Id; p1.First_Name__c = 'Testy'; p1.Last_Name__c = 'Testoferson'; p1.Social_Security_Number__c = '999999998'; p1.Date_of_Birth__c = Date.newInstance(2000, 1, 1); p1.Disabled__c = 'No'; p1.Education__c = 'Unknown'; p1.Gender__c = 'Unknown'; p1.Ethnicity__c = 'No Response'; p1.Race__c = 'African American'; p1.Primary_Language__c = 'Spanish'; p1.Health_Insurance__c = 'Yes'; p1.SSN_Status__c = 'Verified'; p1.Food_Stamps__c = 'No'; p1.Veteran_Code__c = 'No'; p1.WIC__c = 'No'; p1.Marital_Status__c = 'Single'; insert p1; // Add parameters to page URL ApexPages.currentPage().getParameters().put('id', p1.id); } } }
I'm trying to insert the id of a freshly inserted participant into the query string parameter in my test method and it is still returning null, any idea what I'm doing wrong?
Thank you!
-
- jordanm
- April 27, 2012
- Like
- 0
- Continue reading or reply
Apex: Wizard Problem, successful insert yields "Null reference" error
Hello,
I'm ripping my hair out over this wizard controller. I made this off of the Cookbook's Opportunity controller. Basically, if I comment this out, the participant assessment is created/inserted successfully.
//participantanswer.Participant_Assessment__c = participantassessment.Id; //participantanswer.Possible_Answer__c = possibleanswer1; //insert participantanswer;
Without that block commented, my controller looks like this, and I cannot seem to pull the newly created Id of the participantassessment which was successfully created in the previous block.
public class osmController { // These member variables maintain the state of the wizard. // When users enter data into the wizard, their input is stored // in these variables. Participant_Assessment__c participantassessment; Participant_Answer__c participantanswer; private final Participant__c participant; private final Assessment__c assessment; string possibleanswer1 = null; // The next methods return one of each of the member // variables. If this is the first time the method is called, // it creates an empty record for the variable. public osmController() { participant = [select id, name from Participant__c where id = :ApexPages.currentPage().getParameters().get('id')]; assessment = [select id, name from Assessment__c where Name = :ApexPages.currentPage().getParameters().get('asmt') AND Version__c = :ApexPages.currentPage().getParameters().get('version')]; } public List<selectOption> getanswer1() { List<selectOption> options = new List<selectOption>(); //new list for holding all of the picklist options //options.add(new selectOption('', '--None--')); //add the first option of '- None -' in case the user doesn't want to select a value or in case no values are returned from query below for (Possible_Answer__c pa1 : [SELECT Id, Answer_Display__c FROM Possible_Answer__c WHERE Dimension__c = 'Income']) { options.add(new selectOption(pa1.Id, pa1.Id)); //for all records found - add them to the picklist options } return options; //return the picklist options } public Participant__c getParticipant() { return participant; } public Assessment__c getAssessment() { return assessment; } public Participant_Assessment__c getParticipantAssessment() { if(participantassessment == null) participantassessment = new Participant_Assessment__c(); return participantassessment; } public Participant_Answer__c getParticipantAnswer() { if(participantanswer == null) participantanswer = new Participant_Answer__c(); return participantanswer; } public String getpossibleanswer1() { return possibleanswer1; } public void setpossibleanswer1(String possibleanswer1) { this.possibleanswer1 = possibleanswer1; } // The next methods control navigation through // the wizard. Each returns a PageReference for one of the pages // in the wizard. Note that the redirect attribute does not need to // be set on the PageReference because the URL does not need to change // when users move from page to page. public PageReference step1() { return Page.osmStep1; } public PageReference step2() { return Page.osmStep2; } public PageReference step3() { return Page.osmStep3; } // This method cancels the wizard, and returns the user to the // Participants tab public PageReference cancel() { PageReference participantPage = new ApexPages.StandardController(participant).view(); participantPage.setRedirect(true); return participantPage; } // This method performs the final save for all objects, and // then navigates the user to the detail page for the new // participant assessment. public PageReference save() { // Create the participant assessment. Before inserting, use the id field // from the active participant and assessment that are passed via custom button to create // the relationship between the participant and assessment and the participant assessment. participantassessment.Participant__c = participant.Id; participantassessment.Assessment__c = assessment.Id; insert participantassessment; // Create the participant answer. Before inserting, use the id field // that's created once the participant assessment is inserted to create // the relationship between the participant assessment and the participant answer. participantanswer.Participant_Assessment__c = participantassessment.Id; //participantanswer.Possible_Answer__c = possibleanswer1; insert participantanswer; // Finally, send the user to the detail page for // the new participant assessment. PageReference participantassessmentPage = new ApexPages.StandardController(participantassessment).view(); participantassessmentPage.setRedirect(true); return participantassessmentPage; } }
Any tips on how to go about fixing/debugging this would be greatly appreciated.
The exact error I get is:
System.NullPointerException: Attempt to de-reference a null object
Class.osmController.save: line 109, column 1
Line 109 is
participantanswer.Participant_Assessment__c = participantassessment.Id
-
- jordanm
- April 17, 2012
- Like
- 0
- Continue reading or reply
Possible bug with new flow text validation feature
Hello,
In my flow I have a form_SSN textbox and a form_SSN_Status radiolist
here is my validation routine for the form_SSN textbox:
NOT( OR( NOT( OR ( ISBLANK({!form_SSN}), REGEX( {!form_SSN} , "[0-9]{9}"))), AND ( OR ( {!form_SSN_Status} = "Verified", {!form_SSN_Status} = "Unverified"), ISBLANK({!form_SSN})), AND ( OR ( {!form_SSN_Status} = "Refused", {!form_SSN_Status} = "Pending", {!form_SSN_Status} = "Unavailable"), NOT ISBLANK({!form_SSN}) ) ) )
When I select status "verified" or "unverified" I should be getting an error message if I attempt to not enter anything into SSN textbox, however, this is not the case.
The inverse is true, when I select the other statuses and have any value in the textbox the NOT ISBLANK({!field}) function DOES fire an error. This leads me to believe that this is a bug.
NOTE: I have this very same validation routine working as a validation rule on the object level... the only difference is I enclosed everything here with a NOT ( ) because validation rules shoot errors on "true" whereas flow validation errors out on "false".
-
- jordanm
- April 09, 2012
- Like
- 0
- Continue reading or reply
$flow.CurrentDate showing incorrect date/time?
Hello,
Has anyone tried calling the $flow.CurrentDate system variable in flows? This actually seems like a bug. Regardless of what time you invoke the function, it ALWAYS returns 7:00 PM of the PREVIOUS day.
Is there a setting or way to fix this?
-
- jordanm
- December 19, 2011
- Like
- 0
- Continue reading or reply
Create PDF apex plugin from cloud designer webinar & test case question
Hello,
I couldn't find it anywhere, so I reproduced the create and attach PDF plugin from the cloud designer webinar. Here it is for those that may want it.
global class CreateAndAttachPDF implements Process.Plugin { // member variables for status public static final String SUCCESS_CODE = 'SUCCESS'; public static final String ERROR_CODE = 'ERROR'; public String aStatus; public String anErrorDescription; // The main method to be implemented. The Flow calls this at runtime. global Process.PluginResult invoke(Process.PluginRequest request) { // Get record to which pdf needs to be attached String recordID = (String) request.inputParameters.get('recordID'); // Get the attachment content String pdfAttachmentName = (String) request.inputParameters.get('pdfAttachmentName'); String pdfAttachmentContent = (String) request.inputParameters.get('pdfAttachmentContent'); Map<String,Object> result = new Map<String,Object>(); AttachPDF(recordID, pdfAttachmentName, pdfAttachmentContent); result.put('Status', aStatus); result.put('Error Message', anErrorDescription); return new Process.PluginResult(result); } // Returns the describe information for the interface global Process.PluginDescribeResult describe() { Process.PluginDescribeResult result = new Process.PluginDescribeResult(); result.description = 'The CreateAndAttachPDF flow plug-in creates a PDF document and attaches it to specific record'; result.tag = 'PDF Utils'; result.inputParameters = new List<Process.PluginDescribeResult.InputParameter>{ new Process.PluginDescribeResult.InputParameter('recordID', Process.PluginDescribeResult.ParameterType.STRING, true), new Process.PluginDescribeResult.InputParameter('pdfAttachmentName', Process.PluginDescribeResult.ParameterType.STRING, true), new Process.PluginDescribeResult.InputParameter('pdfAttachmentContent', Process.PluginDescribeResult.ParameterType.STRING, true) }; result.outputParameters = new List<Process.PluginDescribeResult.OutputParameter>{ new Process.PluginDescribeResult.OutputParameter('Status', Process.PluginDescribeResult.ParameterType.STRING), new Process.PluginDescribeResult.OutputParameter('Error Message', Process.PluginDescribeResult.ParameterType.STRING) }; return result; } public void AttachPDF(String recordID, String pdfAttachmentName, String pdfAttachmentContent) { Blob pdfAttachment; try { pdfattachment = Blob.toPdf(pdfAttachmentContent); Attachment attach = new Attachment(); attach.ParentId = recordId; attach.Name = pdfAttachmentName; attach.Body = pdfAttachment; insert(attach); aStatus = SUCCESS_CODE; } catch (Exception anException) { astatus = ERROR_CODE; anErrorDescription = anException.getMessage(); } } }
Here is the test case I wrote for it (Doesn't appear in the webinar). I only got it up to 78% coverage, any idea how to get this up to 100? The red problem areas seem to all be in the DescribeResult section.
@isTest public class TestCreateAndAttachPDF { public static testMethod void MyTest() { Profile pf = [Select Id from Profile where Name = 'Sys Admin']; User u = new User(); u.FirstName = 'Test'; u.LastName = 'User'; u.Email = 'testuser@test123456789.com'; u.CompanyName = 'test.com'; u.Title = 'Test User'; u.Username = 'testuser@test123456789.com'; u.Alias = 'testuser'; u.CommunityNickname = 'Test User'; u.TimeZoneSidKey = 'America/Mexico_City'; u.LocaleSidKey = 'en_US'; u.EmailEncodingKey = 'ISO-8859-1'; u.ProfileId = pf.Id; u.LanguageLocaleKey = 'en_US'; insert u; system.runAs(u){ Family__c o = new Family__c(); o.Family_Type__c = 'Other'; insert o; CreateAndAttachPDF plugin = new CreateAndAttachPDF(); Map<String,Object> inputParams = new Map<String,Object>(); string recordID = o.Id; string pdfAttachmentName = 'test intake form'; string pdfAttachmentContent = 'test content'; InputParams.put('recordID', recordID); InputParams.put('pdfAttachmentName', pdfAttachmentName); InputParams.put('pdfAttachmentContent', pdfAttachmentContent); Map<String,Object> outputParams = new Map<String,Object>(); string Status = 'status test'; string ErrorMsg = 'error message test'; outputParams.put('Status',Status); outputParams.put('Error Message',ErrorMsg); Process.PluginRequest request = new Process.PluginRequest(inputParams); Process.PluginRequest request2 = new Process.PluginRequest(outputParams); plugin.invoke(request); plugin.invoke(request2); } } }
-
- jordanm
- December 10, 2011
- Like
- 0
- Continue reading or reply
Test Class for Controller/Flow:Interview
Hello,
I am only getting 66% coverage with the following code, and was wondering how to go about getting full. The lack of coverage happens when the flow/interview is NOT null, but I'm not sure how to give it a value.
Here is my VF page:
<apex:page controller="IntakeController" tabStyle="Case" > <flow:interview name="Universal_Intake" finishLocation="{!FinishPage}" interview="{!myflow}" /> <apex:PageBlock > <apex:outputText style="font-size:150%; color:red; font-weight:bold" value="NOTE: Editing/Deleting below this point will interrupt your Universal Intake flow!" /> <apex:detail subject="{!var_ParticipantId}" relatedList="true" /> </apex:PageBlock> <apex:PageBlock > <apex:detail subject="{!var_FamilyId}" relatedList="true" /> </apex:PageBlock> </apex:page>
My Controller:
public class IntakeController { public Flow.Interview.Universal_Intake myflow {get;set;} public String getVar_ParticipantId() { if (myflow==null) return ''; else return myflow.var_ParticipantId; } public String getVar_FamilyId() { if (myflow==null) return ''; else return myflow.var_FamilyId; } public String getVar_AddressId() { if (myflow==null) return ''; else return myflow.var_AddressId; } public PageReference getFinishPage(){ //does address ID exist? if (getVar_AddressId()=='') { //no, use family ID instead which will exist PageReference p = new PageReference('/' + getVar_FamilyId() ); p.setRedirect(true); return p; } else { //yes, use addressID PageReference p = new PageReference('/' + getVar_AddressId() ); p.setRedirect(true); return p; } } }
My Test class:
@isTest public class TestIntakeController { public static testMethod void testMyController() { IntakeController controller = new IntakeController(); PageReference testFinishPage = controller.getFinishPage(); String GetParticipantId = controller.getVar_ParticipantId(); String GetFamilyId = controller.getVar_FamilyId(); String GetAddressId = controller.getVar_AddressId(); } }
I know I have to account for interviews that are NOT null, but again, am not sure how to do so. Any help would be appreciated.
NOTE: I do know about the flow designer forums, but posted here instead because those boards seem much less active than these. Apologies.
-
- jordanm
- December 08, 2011
- Like
- 0
- Continue reading or reply
Suggestions for Improving Cloud Designer
Hello,
I've created some very elaborate flows with the cloud designer. Here is some feedback.
1) We should be able to disable/remove/hide the "previous" button at various points.
2) One of thet largest issues I'm running into with more elaborate flows is the clearing of screen input fields. Sometimes you need to loop through a screen, and it shouldn't retain the previously entered values for its inputs.
3) Text validation(regex, etc.) for screen input fields. Don't simply rely on object level validation.
4) not as critical as the above--but auto-layout in the desktop designer was a huge time saver for very large and elaborate flows. I realize this might be tricky to implement.
I did fill out the official survey in the cloud tool with these suggestions too.
-
- jordanm
- December 07, 2011
- Like
- 0
- Continue reading or reply
Dependent Textboxes
Hello,
I'm new to Apex and was wondering if the following scenario is possible in Apex. I'm using the cloud flow designer and need to accomplish this:
1) User selects an income frequency, i.e. weekly bi-weekly monthly etc.
2) We collect the last 4 weeks of paystubs, meaning that if weekly is selected the user should see Amount 1 Amount 2 Amount 3 Amount 4 fields/textboxes
3) If bi-weekly is selected two of the amount fields would show, monthly would show just one.
4) Amount 1 - 4 fields exist on the object level, these are not dynamically created fields, so I would just want to show/hide them based on what income frequency the user has selected
Can I code an Apex class to do this and call it in the cloud flow designer to meet my need?
Thank you!
-
- jordanm
- November 30, 2011
- Like
- 0
- Continue reading or reply
Salesforce object: columns to rows
Hello,
How would one convert the data in an object in the following way:
From this:
Object A: 1 record
ContactId,Phone,MobilePhone,HomePhone
a000axb03423xbg,222-222-2222,111-111-1111,000-000-0000
To this:
Object B: 3 records
ContactId,PhoneToCall
a000axb03423xbg,222-222-2222
a000axb03423xbg,111-111-1111
a000axb03423xbg,000-000-0000
This is a data conversion that I'd have to be able to schedule out of SF on a nightly basis.
This could be accomplished in SQL pretty easily or if I could replicate my force data down into a SQL database, but I'm not finding a way to do it in SOQL. Any suggestions?
- jordanm
- August 19, 2013
- Like
- 0
- Continue reading or reply
Required drop down lists
- jordanm
- July 24, 2012
- Like
- 0
- Continue reading or reply
Change look/feel of Visual Flows with Visualforce page?
The '12 summer release notes state that you can now alter the layout, look, and feel of flows with visualforce page/css etc.
Is there any documentation on how to accomplish this?
- jordanm
- May 14, 2012
- Like
- 0
- Continue reading or reply
Images in PDFs broken in Summer '12
Hi,
Anybody else having problems with images in summer '12?
Our sandbox has been updated and pdf generation now gives an error 'PDF generation failed. Check the page markup is valid.'
Test example below gives same issue. Any ideas?
<apex:page renderas="pdf"> <h1>Congratulations</h1> This is your new Page <img src="http://www.developerforce.com/assets/images/discussions/banner.gif"></img> </apex:page>
A case has been logged -but just wondering if there is a quick fix.
Thanks!
Rich.
- Richie D
- May 14, 2012
- Like
- 0
- Continue reading or reply
After update several hours ago renderAs PDF doesn't seem to be working?
It won't even work for the canned quote2PDF example in the cookbook...
I get this error message on an otherwise blank failure page: "PDF generation failed. Check the page markup is valid. "
Anyone else seeing this?
- jordanm
- May 12, 2012
- Like
- 0
- Continue reading or reply
Help with Loop Construction
Hi,
I need a hand building this loop for the following scenario. I have a grandparent that is passed to a page via query string, this grandparent refers to multiple parents, and those multiple parents each have multiple children
I want to yield this:
grandparent 1
+++parent 1
++++++child a
++++++child b
+++parent 2
++++++child c
++++++child d
The loop in the controller is confounding me.
parents = [SELECT id,Name FROM Parent__c WHERE Grandparent__c=:grandparentId]; for(Parent__c parents1:parents) { // fetch the values by SOQL on the basis of parent id children=[select id,Name FROM Child__c WHERE Parent__c=:parents1.id]; system.debug('size'+ parents.size()); system.debug('>>>>>>>>>>>>>>>>>'); children1.addall(children); }
This is clearly incorrect. It is going to build a list of ALL the parents of the grandparent and then take ALL of their children and store them in children1 variable. This won't accomplish the tree-type view I want, it will instead show this:
grandparent 1
+++parent 1
++++++child a
++++++child b
++++++child c
++++++child d
+++parent 2
++++++child a
++++++child b
++++++child c
++++++child d
How should I build this loop?
- jordanm
- May 10, 2012
- Like
- 0
- Continue reading or reply
Hide/Remove the Previous button from last screen
In the last screen of my flow, I display the various input fields submitted by the user as a confirmation of what s/he enterred. This screen is preceeded by a Record Create task which posted the data to my custom object. All is well except for the fact that my last screen displays the default buttons of "Previous" and "Finish". How do I remove or hide the Previous button so a user does not make an inadvertent double entry by clicking the Previous button and invoking the Record Create a second time?
- emandra_kf
- April 24, 2012
- Like
- 0
- Continue reading or reply
Possible bug with new flow text validation feature
Hello,
In my flow I have a form_SSN textbox and a form_SSN_Status radiolist
here is my validation routine for the form_SSN textbox:
NOT( OR( NOT( OR ( ISBLANK({!form_SSN}), REGEX( {!form_SSN} , "[0-9]{9}"))), AND ( OR ( {!form_SSN_Status} = "Verified", {!form_SSN_Status} = "Unverified"), ISBLANK({!form_SSN})), AND ( OR ( {!form_SSN_Status} = "Refused", {!form_SSN_Status} = "Pending", {!form_SSN_Status} = "Unavailable"), NOT ISBLANK({!form_SSN}) ) ) )
When I select status "verified" or "unverified" I should be getting an error message if I attempt to not enter anything into SSN textbox, however, this is not the case.
The inverse is true, when I select the other statuses and have any value in the textbox the NOT ISBLANK({!field}) function DOES fire an error. This leads me to believe that this is a bug.
NOTE: I have this very same validation routine working as a validation rule on the object level... the only difference is I enclosed everything here with a NOT ( ) because validation rules shoot errors on "true" whereas flow validation errors out on "false".
- jordanm
- April 09, 2012
- Like
- 0
- Continue reading or reply
Buttons Intermittently Disappearing!
This is a snapshot of the first page of the new visual workflow I have recently deployed to production. As you can see, it has no buttons. No "Next", no "Finish", no nothin'.
If I hit refresh, however, there is a 75% chance the buttons will appear. (All percent chances in this post are estimates.) There is a 50% chance the buttons will appear or not appear on ALL pages in my visual workflow. I cannot find any consistant reason for this. I have tried different users, different profiles, different browsers. It is relatively unpredictable on the same computer, with only seconds between attempts, and have been able to reproduce it on multiple computers. It truly seems to be random! Does anyone know what is going on here? I'd hate to have to tell my 280+ users that if they get no buttons they just have to keep hitting Refresh until they come up!
I can provide any requested information on my visual workflow if needed.
- markross__c
- March 26, 2012
- Like
- 0
- Continue reading or reply
$flow.CurrentDate showing incorrect date/time?
Hello,
Has anyone tried calling the $flow.CurrentDate system variable in flows? This actually seems like a bug. Regardless of what time you invoke the function, it ALWAYS returns 7:00 PM of the PREVIOUS day.
Is there a setting or way to fix this?
- jordanm
- December 19, 2011
- Like
- 0
- Continue reading or reply
Visualforce Dependent Picklist actionSupport Problem
Hi,
The Problem I’m having is that the actionSupport function SearchTemplates from my dependent picklist is only running once when I set the value. When I change the values again it does not run my SearchTemplates method. What is happening is that Salesforce is removing the onchange event from my select list after running the action once. I think this maybe a Salesforce bug. Is there a workaround with out changing my data model?
Below is a simple code example of what I am trying to do:
Visualforce Page
<apex:page controller="TemplateCont" >
<apex:form >
<apex:actionRegion >
<apex:inputField value="{!aTemplate.Category__c}"/>
<apex:inputField value="{!aTemplate.Subcategory__c}">
<apex:actionSupport action="{!SearchTemplates}" event="onchange" rerender="matchingTemplates" status="status"/>
</apex:inputField>
<apex:actionStatus startText=" Please wait..." id="status"/>
</apex:actionRegion>
<apex:pageBlock title="Matching Templates" id="matchingTemplates" >
{!MatchingTemplates.size}
</apex:pageBlock>
</apex:form>
</apex:page>
Controller
public with sharing class TemplateCont {
public Template__c aTemplate{get; set;}
public List<Template__c> matchingTemplates{get; private set;}
public TemplateCont(){ aTemplate = new Template__c(); matchingTemplates = new List<Template__c>(); } public void SearchTemplates(){ matchingTemplates = [SELECT name, category__c, subcategory__c FROM Template__c where category__c=:aTemplate.Category__c and subCategory__c=:aTemplate.Subcategory__c]; } }
Would be greatfull for any help.
Thanks
Peter
- Gazza
- July 30, 2010
- Like
- 0
- Continue reading or reply