0

I am creating a form that people can fill out and submit, that creates "CSAT_Survey__c" objects. I am looking to link these objects to Cases, so I have created a master(case) - detail (CSAT_Survey__c) relationship between the two. I have tried to create a URL by concatenating the salesforce baseURL, the CSAT ID and the "caID" Case ID, but I have not been able to get the merge working properly. I was not able to tangibly connect the case record to a CSAT. Have I missed a step in setting something up on the case object to make this possible? Below is my page and controller.

<apex:page standardstylesheets="false" sidebar="false" showHeader="false" standardController="CSAT_Survey__c" extensions="CSATSurveyController">

<title>CSAT Survey</title>
<apex:include pageName="csPageHeader" />   

        <apex:pageMessages />

    <apex:form >
<div class="span10">
<div class="control-groupset">
    <div class="control-groupset-titlebar">Have We Resolved Your Issue?</div>
    <div class="control-groupset-content">

    Were we able to resolve your issue?
<apex:selectRadio value="{!CSAT_Survey__c.Issue_Resolved__c}">
    <apex:selectOption itemValue="Yes" itemLabel="Yes"/>
    <apex:selectOption itemValue="No" itemLabel="No"/>
</apex:selectRadio>
    </div>
    </div>
    </div>


<div class="span10">
<div class="control-groupset">
    <div class="control-groupset-titlebar">If we have:</div>
    <div class="control-groupset-content">

    R Question 1
    <div>
<apex:selectRadio value="{!CSAT_Survey__c.Resolved_Q1__c}">
    <apex:selectOption itemValue="1" itemLabel="1"/>
    <apex:selectOption itemValue="2" itemLabel="2"/>
    <apex:selectOption itemValue="3" itemLabel="3"/>
    <apex:selectOption itemValue="4" itemLabel="4"/>
    <apex:selectOption itemValue="5" itemLabel="5"/>
    <apex:selectOption itemValue="6" itemLabel="6"/>
    <apex:selectOption itemValue="7" itemLabel="7"/>
    <apex:selectOption itemValue="8" itemLabel="8"/>
    <apex:selectOption itemValue="9" itemLabel="9"/>
    <apex:selectOption itemValue="10" itemLabel="10"/>
</apex:selectRadio>
    </div>

    R Question 2
    <div>
<apex:selectRadio value="{!CSAT_Survey__c.Resolved_Q2__c}">
    <apex:selectOption itemValue="1" itemLabel="1"/>
    <apex:selectOption itemValue="2" itemLabel="2"/>
    <apex:selectOption itemValue="3" itemLabel="3"/>
    <apex:selectOption itemValue="4" itemLabel="4"/>
    <apex:selectOption itemValue="5" itemLabel="5"/>
    <apex:selectOption itemValue="6" itemLabel="6"/>
    <apex:selectOption itemValue="7" itemLabel="7"/>
    <apex:selectOption itemValue="8" itemLabel="8"/>
    <apex:selectOption itemValue="9" itemLabel="9"/>
    <apex:selectOption itemValue="10" itemLabel="10"/>
</apex:selectRadio>
    </div>

    R Question 3
    <div>
<apex:selectRadio value="{!CSAT_Survey__c.Resolved_Q3__c}">
    <apex:selectOption itemValue="1" itemLabel="1"/>
    <apex:selectOption itemValue="2" itemLabel="2"/>
    <apex:selectOption itemValue="3" itemLabel="3"/>
    <apex:selectOption itemValue="4" itemLabel="4"/>
    <apex:selectOption itemValue="5" itemLabel="5"/>
    <apex:selectOption itemValue="6" itemLabel="6"/>
    <apex:selectOption itemValue="7" itemLabel="7"/>
    <apex:selectOption itemValue="8" itemLabel="8"/>
    <apex:selectOption itemValue="9" itemLabel="9"/>
    <apex:selectOption itemValue="10" itemLabel="10"/>
</apex:selectRadio>
    </div>


    Additional Comments
    <div>
    <apex:inputTextArea rows="5" value="{!CSAT_Survey__c.Resolved_Comments__c}" label="Additional Comments" />  
    </div>

    <div>
    <apex:commandLink id="ResolvedSubmit" action="{!save}" styleclass="btn btn btn-primary" style="background-color : Green; background-image:none; color:#002233;">Submit</apex:commandLink>
    </div>

    </div>
    </div>
    </div>



<div class="span10">
<div class="control-groupset">
    <div class="control-groupset-titlebar">If we were not able to today:</div>
    <div class="control-groupset-content">

    UR Question 1
    <div>
<apex:selectRadio value="{!CSAT_Survey__c.Unresolved_Q1__c}">
    <apex:selectOption itemValue="1" itemLabel="1"/>
    <apex:selectOption itemValue="2" itemLabel="2"/>
    <apex:selectOption itemValue="3" itemLabel="3"/>
    <apex:selectOption itemValue="4" itemLabel="4"/>
    <apex:selectOption itemValue="5" itemLabel="5"/>
    <apex:selectOption itemValue="6" itemLabel="6"/>
    <apex:selectOption itemValue="7" itemLabel="7"/>
    <apex:selectOption itemValue="8" itemLabel="8"/>
    <apex:selectOption itemValue="9" itemLabel="9"/>
    <apex:selectOption itemValue="10" itemLabel="10"/>
</apex:selectRadio>
    </div>

    UR Question 2
    <div>
<apex:selectRadio value="{!CSAT_Survey__c.Unresolved_Q2__c}">
    <apex:selectOption itemValue="1" itemLabel="1"/>
    <apex:selectOption itemValue="2" itemLabel="2"/>
    <apex:selectOption itemValue="3" itemLabel="3"/>
    <apex:selectOption itemValue="4" itemLabel="4"/>
    <apex:selectOption itemValue="5" itemLabel="5"/>
    <apex:selectOption itemValue="6" itemLabel="6"/>
    <apex:selectOption itemValue="7" itemLabel="7"/>
    <apex:selectOption itemValue="8" itemLabel="8"/>
    <apex:selectOption itemValue="9" itemLabel="9"/>
    <apex:selectOption itemValue="10" itemLabel="10"/>
</apex:selectRadio>
    </div>

    UR Question 3
    <div>
<apex:selectRadio value="{!CSAT_Survey__c.Unresolved_Q3__c}">
    <apex:selectOption itemValue="1" itemLabel="1"/>
    <apex:selectOption itemValue="2" itemLabel="2"/>
    <apex:selectOption itemValue="3" itemLabel="3"/>
    <apex:selectOption itemValue="4" itemLabel="4"/>
    <apex:selectOption itemValue="5" itemLabel="5"/>
    <apex:selectOption itemValue="6" itemLabel="6"/>
    <apex:selectOption itemValue="7" itemLabel="7"/>
    <apex:selectOption itemValue="8" itemLabel="8"/>
    <apex:selectOption itemValue="9" itemLabel="9"/>
    <apex:selectOption itemValue="10" itemLabel="10"/>
</apex:selectRadio>
    </div>

     Additional Comments
    <div>
    <apex:inputTextArea rows="5" value="{!CSAT_Survey__c.Unresolved_Comments__c}" label="Additional Comments" />  
    </div>

    <div>
    <apex:commandLink id="UnresolvedSubmit" action="{!save}" styleclass="btn btn btn-primary" style="background-color : Green; background-image:none; color:#002233;">Submit</apex:commandLink>
    </div>

    </div>
    </div>
    </div>


</apex:form>        





</apex:page>

Controller Below

public class CSATSurveyController {

public CSAT_Survey__c CSAT {get; set;}

public String templateURL {get; set;}

public String caseId {get; set;}

public String surveyId {get; set;}

public String baseURL;

public CSATSurveyController (ApexPages.StandardController controller){
    this.CSAT = (CSAT_Survey__c)controller.getRecord();
    surveyId = Apexpages.currentPage().getParameters().get('id');
    caseId   = Apexpages.currentPage().getParameters().get('caId');
    String urlBase = URL.getSalesforceBaseUrl().toExternalForm();
    baseURL = urlBase;


}


public void setCaseAndURL(){
   CSAT_Survey__c newSurvey =  [SELECT Id FROM CSAT_Survey__c Where Case__r.Id = :caseId];
    templateURL = baseURL + 'id='+newSurvey.Id +'&caId='+'{!Case.Id}';

}




public pagereference Save() {

    insert CSAT;

    PageReference pg = Page.CSATThankYouTestPage;
    pg.setredirect(true);

    return pg; 

}



}

Feel free to let me know if I have started down the wrong path here, but if I am missing something on the right track, any input would go a long way.

Many Thanks, CP

7
  • where you want to put link on page ? – Himanshu Nov 19 '15 at 20:37
  • I would like it to be in the URL, I do not necessarily want to have that link on the page. When they fill out the survey, I just want it to be available in the related lists for that case (as a related record. – Chris P Nov 19 '15 at 20:39
  • record will be of CSAT_Survey__c object correct ? – Himanshu Nov 19 '15 at 20:41
  • correct. The form will create a CSAT_Survey__c object, and I want it to be linked to the case it is related to. – Chris P Nov 19 '15 at 20:43
  • You can mentioned that Case is parent object of CSAT_Survey__c object in that case you can add CSAT_Survey__c as related list on Case object page layout – Himanshu Nov 19 '15 at 20:45
1

As per the chat discussion if you want to link Case with your CSAT_Survey__c object update your save method as follows

public pagereference Save() {

    CSAT.Case__c = caseId;
    upsert CSAT;

    PageReference pg = Page.CSATThankYouTestPage;
    pg.setredirect(true);

    return pg; 

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.