6

Question

Is there a URL parameter I can use to control the page a user lands on after submitting a record for approval?

Background

I'm building out an approval process that is built on an object (agreementApprovalId property of the extension) related to the primary object (Apttus__APTS_Agreement__c). I've built a helper page on the parent object that calls the submit action on the child. Now I need to get Salesforce to return them to the parent object once the approval is submitted.

I've inspected the standard url which uses the retURL parameter, but the system ignores the value I pass in. Is there a different parameter I should be using?

Visualforce Page

<apex:page standardController="Apttus__APTS_Agreement__c" extensions="AgreementApprovalRedirect" 
        action="{!IF(agreementApprovalFound,
                     URLFOR($Action.Discount_Approval__c.Submit,
                            agreementApprovalId,
                            [retURL = '/' + Apttus__APTS_Agreement__c.Id]),
                     null)}">
</apex:page>
2
  • 1
    retURL is generally where you land after hitting cancel. Try saveURL. Also how about an on load action method, which returns an explicit Page reference after submitting for Approval programatically? – techtrekker May 14 '13 at 19:00
  • Thanks for the tips, tried saveURL, no dice. Submitting the approval programmatically is my back-up, just trying to see if there is a way to get by without doing that ... – Ralph Callaway May 14 '13 at 19:53
2

Since you are already using a VF page for helping the approval submission why not create an method with return type of pagereference in your AgreementApprovalRedirect extension and use it to redirect to the desired page?

The code would look something like this:

Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();  
req1.setComments('Submitted for Approval');
req1.setObjectId(agreementApprovalId);
Approval.ProcessResult result = Approval.process(req1); 

if(result.isSuccess)
{
  return new pagereference('pageURL');
}
3
  • Good suggestion, but creating the page references in the controller doesn't deal with the fact the standard approval page doesn't seem to respect retURL or saveURL params. Or am I misunderstanding this and you're saying that I should submit the approval in the vf controller itself? If so, could you clarify in your answer and I'll accept – Ralph Callaway Jun 5 '13 at 16:26
  • Hi, Since you are already having a vf page i was suggesting to have method which will submit the approval request and redirect to the required page. The code should look something like Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest(); req1.setComments('Submitted for Approval'); req1.setObjectId(agreementApprovalId); Approval.ProcessResult result = Approval.process(req1); – Modem Jun 6 '13 at 3:20
  • Totally, I got you on that. If you could put edit your answer to incorporate your comment I'll accept and upvote. – Ralph Callaway Jun 7 '13 at 0:45

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.