function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ahmad HelalAhmad Helal 

Custom Buton CancelURL not working

I have a custom button on the opportuntiy related list on the contact record as follows:
/setup/ui/recordtypeselect.jsp?ent=Opportunity&retURL=%2F{!Contact.Id}&save_new_url=/006/e?lookupcmpgn=1&cancelURL=%2F{!Contact.Id}&retURL=%2F{!Contact.Id}&ent=Opportunity&conid={!Contact.Id}&opp6={!Contact.LeadSource}&CF00N80000004cLg4={!Contact.Name}&CF00N80000004cLg4_lkid={!Contact.Id}
It is working as expected with 1 exception, if the user clicks "cancel" on the new opportunity record AFTER they've already selected the record type; it takes them back to the home screen instead of back to the orignating contact record. I've been playing around with the CancelURL and the retURL and I can't get it to work. The odd thing is if the user hits cancel on the record type selection screen it works as expected, it's just if they continue past the record type selection to the new record then hit cancel. 
pconpcon
Once you've selected the record type, what does the URL look like?  Does it contain your cancelURL?
Ahmad HelalAhmad Helal
Pcon - Good Catch. After the record type is selected the URL is as follows:
https://na8.salesforce.com/006/e?lookupcmpgn=1&RecordType=012C0000000GFFg&CF00N80000004cLg4=Rudy+Harrelson&CF00N80000004cLg4_lkid=003C0000020xmTC&conid=003C0000020xmTC&ent=Opportunity&ent=Opportunity&opp6=TCi

So the CancelURL and the retURL are not passing through to the new url. So now that we know that is happening what do we do to fix it?
pconpcon
To be honest, I'm ashamed at myself for not seeing it earlier.  I think your problem is that you did not escape your '?' in your save_new_url.  Try using the following URL for your button
 
/setup/ui/recordtypeselect.jsp?ent=Opportunity&retURL=%2F{!Contact.Id}&save_new_url=%2F006%2Fe%3Flookupcmpgn=1&cancelURL=%2F{!Contact.Id}&retURL=%2F{!Contact.Id}&ent=Opportunity&conid={!Contact.Id}&opp6={!Contact.LeadSource}&CF00N80000004cLg4={!Contact.Name}&CF00N80000004cLg4_lkid={!Contact.Id}

I also encoded your slashes to %2F as well.
Ahmad HelalAhmad Helal
Hmmm..... I don't believe that's the issue because the other parameters (field values) were being passed through to the new url, just for sanity I tried your code snippet and I'm still getting the same issue. Hitting cancel while on teh opportunity edit screen takes you back to the home screen not the orginating contact record.