You need to sign in to do that
Don't have an account?
Force.com Sites Survey Form, URL not working as expected pelase help!
Hey there,
I have a site which is used to automatically send a link to a client at certain times and then once submitted automatically attach to the clients account. This all works fine, I am just having one problem with attaching it to another custom object called "office__c".
This is the url that is sent in the automatic email. http://destinyliveoffice.force.com/DestinySurvey?acct={!Account.Id}&Off={!Account.OfficeId__c}&Sur=120DAIPC
However, upon clicking the url....the account ID is filled with the correct ID, however the officeID for some reason will show the office name.
E.G. http://destinyliveoffice.force.com/DestinySurvey?acct={!Account.Id}&Off=Sydney&Sur=120DAIPC
This is preventing the survey upon being submitted from being added to both the account and the office. What could be causing this? please help?
My class and VF page are as below:
public class extDestinySurvey { public Destiny_Survey__c Dess {get;set;} private Id AccountId { get { if ( AccountId == null ) { String acctParam = ApexPages.currentPage().getParameters().get( 'acct' ); try { if ( !String.isBlank( acctParam ) ) AccountId = Id.valueOf( acctParam ); } catch ( Exception e ) {} } return AccountId; } private set; } Private Id OfficeId { get { if ( OfficeId == null ) { String OffParam = ApexPages.currentPage().getParameters().get( 'Off' ); try { if ( !String.isBlank( OffParam ) ) OfficeId = Id.valueOf( OffParam ); } catch ( Exception e ) {} } return OfficeId; } Private set; } public extDestinySurvey(ApexPages.StandardController controller) { Dess = (Destiny_Survey__c)controller.getRecord(); Dess = (Destiny_Survey__c) controller.getRecord(); Dess.Survey_Code__c = ApexPages.currentPage().getParameters().get('Sur'); } public PageReference saveDestinySurvey() { Dess.Account__c = AccountId; Dess.Office__c = OfficeId; upsert Dess; // Send the user to the detail page for the new account. return new PageReference('/apex/Destiny_Survey_Thank_You'); } }and
<apex:page standardController="Destiny_Survey__c" extensions="extDestinySurvey" showHeader="false" > <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> <script src="{!URLFOR($Resource.charCounter)}" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $('.countable1').jqEasyCounter({ 'maxChars': 250, 'maxCharsWarning': 40, 'msgFontSize': '12px', 'msgFontColor': '#000', 'msgFontFamily': 'Verdana', 'msgTextAlign': 'left', 'msgWarningColor': '#F00', 'msgAppendMethod': 'insertAfter' }); }); </script> <style type="text/css"> body { font-family: "Arial", "Helvetica", "Verdana", "Sans-Serif"; margin: 0px; padding: 12px; } img { border: 0px none #ffffff; margin: 0px; padding: 0px; } [id*=SurveyTitle] { font-size: 24px; } [id*=ProductServiceSection] { font-size: 12px; } [id*=FeedbackSection] { font-size: 12px; } [id*=Buttons] { font-size: 12px; } </style> </head> <img alt="" src="{!$Resource.Destiny_Logo}" /> <br /> <br /> <apex:form id="myForm"> <apex:pageBlock id="SurveyTitle" title="Destiny Survey" mode="edit"> <apex:pageBlockSection id="FeedbackSection" title="Feedback" columns="1"> <apex:InputField id="Rating" label="Out of 10 how likely are you to refer Destiny to a friend or colleague?" value="{!Destiny_Survey__c.How_likely_are_you_to_refer_Destiny__c}" /> <apex:pageBlockSectionItem > <apex:outputlabel value="" /> <c:flexslidercomponent minSliderValue="0" maxSliderValue="10" startSliderValue="{!Destiny_Survey__c.How_likely_are_you_to_refer_Destiny__c}" boundDomId="{!$Component.FeedbackSection.Rating}" width="180" /> </apex:pageBlockSectionItem> <apex:inputTextarea id="Explanation" label="Please explain why you gave your rating." StyleClass="countable1" value="{!Destiny_Survey__c.Explain_why_you_gave_your_rating__c}" rows="5" cols="100"/> </apex:pageBlockSection> <apex:pageBlockButtons id="Buttons" location="bottom"> <apex:commandButton value="Submit" action="{!saveDestinySurvey}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
All Answers
Please see this post about id.ValueOf(). This doesn't seems to be a supported by sf from APIv29 onwards.
https://developer.salesforce.com/forums/?id=906F0000000929ZIAQ
instead of
Also while forming URL "http://destinyliveoffice.force.com/DestinySurvey?acct={!Account.Id}&Off={!Account.OfficeId__c}&Sur=120DAIPC"
Can you try below:
I am assuming that "OfficeId__c" is a lookup field.
PS: if this answers your question then hit Like and mark it as solution!
1. Where you forming this link? In a Custom button?
2. Did you made sure that data type of OfficeId__c is "Lookup" or "Master-Detail"
2. Can you change parameter name from "Off" to "OffId" in URL. I am not sure if browser treating your "Off" as something different if it is keywork for it. After this change, make sure you do correspoding changes in Controller of DestinySurvey VF page to aquire "OffId" rather than "Off".
3. No need to change from Lookup to Master-Detail as it will not impact on what you facing.
thank you for all your help firstly. I have tried your suggestions and the url is back to rendering as offID=Melbourne (rather than, offId=0980958094). I am not sure what I am doing wrong, why would accountId work and not office id. This is my class and URL.
and URL
http://destinyliveoffice.force.com/DestinySurvey?acct={!Account.Id}&OffId={!Account.Office__c}&Sur=120DAIPC