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
JagadeesJagadees 

Return URL in Custom Link Button for Object with two diff record types

Hello friends,
I have two record types in my task object - one for my leads & another one for opportunity. Whenever users try to create a new task from a lead/opportunity related list, he/she is shown a choice to select any one of these record types and the respective page will opens up for the creation of the task. This is little cumbersome as they may end up choosing an irrelevant record type at times.
 
 As a solution, I am trying to create a custom list button with content source as URL passing the record type there -  as this will redirect to the concerned page layout directly. 
 
Now the issue here is, I have two diff VF pages for my leads. When the lead status is Open_not contacted & open-suspended, then he/she will be shown the "LeadPage" VF page & when the lead status is Working Contacted, he will be shown the "LeadDetails" VF page. Both these pages have the related list to create new task. 


I wrote the button func as - 
/00T/e?who_id={!Lead.Id}&retURL=%2Fapex%2FLeadDetails%3Fid%3D{!Lead.Id}%26nooverride%3D1&RecordType=0126xxxxxxxxx&ent=Task
 
How can I make the custom button dynamic in a way that it will redirect to the page from where it was moved from? Can I get some help in this? Do I need to write an Onclick JS button instead of Custom URL?