You need to sign in to do that
Don't have an account?
Devendra@SFDC
retURL with multiple parameters
Hello Folks,
How to use retURL with multiple parameters in apex method?
Thanks,
Devendra
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Hello Folks,
How to use retURL with multiple parameters in apex method?
Thanks,
Devendra
Okay, so the vital piece of information was that the URL posted was that generated after clicking the 'cancel' button on the opportunity edit page, rather than that generated by the controller.
Having tried this in my dev org, it turns out that the URLEncoding isn't needed when you add the parameters via the PageReference.getParameters(), as this does the encoding for you.
The following should do the trick:
All Answers
I tried with following code,
At the place of "&" I have used '%26' and it started working.
Is there any other solution?
Thanks,
Devendra
That is the correct way to do it. Essentially you have a parameter that actually contains a full URL, including the query string separator '?' and the parameter separator '&'. You have to URL encode these characters, otherwise they will be interpreted as part of the main URL, so in this case when the browser hits the '&' between accountId and contactid, it is interpreted as the end of the returl parameter, which no doubt breaks your URL.
You should URL encode everything in the value (e.g. the right hand side of the '=') of each parameter.
Hello Bob, Thanks for the quick response.
"You should URL encode everything in the value (e.g. the right hand side of the '=') of each parameter."
Can you please let me know how to encode that part?
Thanks,
Devendra
When you are adding parameters to the URL, its better to add them one at a time as an URL encoded string, rather than putting them all in the page reference.
Thus you'd have something like:
Hi Bob,
I have tried below code:
It gives the error as "URL No Longer Exists". Encode add the some extra characters in URL string. What may be the cause?
Thanks,
Devendra
Encode makes characters URL-safe.
What does the URL look like?
Before clicking on Cancel button
https://na12.salesforce.com/006U0000009asCIIAY/e?retURL=%252Fapex%252FPageRetURL2%253Faccountid%253D001U000000M4q4iIAB%2526contactid%253D003U000000OO25NIAT
After clicking on Cancel button
https://na12.salesforce.com/006U0000009asCIIAY/%2Fapex%2FPageRetURL2%3Faccountid%3D001U000000M4q4iIAB%26contactid%3D003U000000OO25NIAT
Thanks,
Devendra
I can't see how the code I posted could generate that - for example, the '/e' has gone missing.
Can you post the code from your controller.
I am using one controller method.
this method open an Opportunity in Edit mode. On Cancel it should navigate to PageRetURL2 with those two param's.
which is not happeing when I use URLEncode.
I have tried URLDecode, and it works. But we should use URLEncode, Am I correct?
Thanks,
Devendra
Decode won't do anything as the string wouldn't be url encoded at that point.
I don't understand where the 'retURL' parameter could have gone - the code that you have posted doesn't look like it generated the code above, as the parameter is missing its name. Rather the URL looks like it has been concatenated with its parameters.
I'm going to try this on my dev org to see if I can figure it out - I'm using much the same technique in my code and its working fine.
Okay, so the vital piece of information was that the URL posted was that generated after clicking the 'cancel' button on the opportunity edit page, rather than that generated by the controller.
Having tried this in my dev org, it turns out that the URLEncoding isn't needed when you add the parameters via the PageReference.getParameters(), as this does the encoding for you.
The following should do the trick:
Its working now, very well explained by you!!
Thanks,
Devendra