I am having issues understanding how to pass the {!Case.Id} value to a PageReference in a visualforce class.
My VF Page is:
<apex:page standardController="Case" extensions="escalateToJiraController" >
<apex:form >
<apex:pageBlock title="Escalate Case" mode="edit">
<apex:PageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
<apex:commandButton value="Cancel" action="{!cancel}" onclick="window.close()"/>
</apex:PageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:outputField value="{!Case.CaseNumber}"/>
<apex:inputField value="{!Case.Escalation_Priority__c}"/>
<apex:inputField style="width: 500px" value="{!Case.Escalation_Subject__c}"/>
<apex:outputText label="Instructions" escape="false" value="
Please provide a complete problem description. Provide all relevant information including hostnames"/>
<apex:outputText label=" " escape="false" value="
and specific times for each relevant event. Below that, please paste, and complete, the appropriate"/>
<apex:outputText label=" " escape="false" value="
Escalation Template from the CS Debugging Guide."/>
<apex:inputField style="width: 500px; height: 500px" value="{!Case.Escalation_Description__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
My Controller:
public class escalateToJiraController {
ApexPages.StandardController controller;
public escalateToJiraController(ApexPages.StandardController con){
controller = con;
}
public PageReference save() {
controller.save();
PageReference pageRef = new PageReference('http://somewebsite.com/sfdc/jira-test.php?token=8675309&case={!Case.Id}');
return pageRef;
}
}
I think I need to use getParameters(), but am not really finding examples that I am able to make much sense of. Pretty new at the VF/Apex stuff.
Any tips appreciated!
Best Answer
You have to add the parameter explicitly. My favorite way to do this is using getParameters: