+ Start a Discussion
azar khasimazar khasim 

want to make a dynamic url? for page reference to lead edit page in VF Page!want to make a dynamic url? for page reference to lead edit page in VF Page!

want to make a dynamic url? for page reference to lead edit page in VF Page!

My PageReference Code:

 public pagereference createLead(){
       
        pagereference cl1=new pagereference('/lightning/o/Lead/new?count=1&nooverride=1&useRecordTypeCheck=1&navigationLocation=MRU_LIST&backgroundContext=%2Flightning%2Fo%2FLead%2Flist%3FfilterName%3DRecent');
        cl1.setRedirect(true);
        return cl1;
    }

Please give me a solution for this URL to be dynamic.

Thanks and Regards,
Azar Khasim.
azar khasimazar khasim
The below URL is for Lead Edit Page in Lightning.
I want to redirect to that page but I need a dynamic URL for performing the operation all over.


('/lightning/o/Lead/new?count=1&nooverride=1&useRecordTypeCheck=1&navigationLocation=MRU_LIST&backgroundContext=%2Flightning%2Fo%2FLead%2Flist%3FfilterName%3DRecent');

Please provide me a solution for this URL to be Dynamic.


Thanks and Regards,
Azar Khasim.​​​​​​​
David Zhu 🔥David Zhu 🔥
To append parameters to Pagereference, try using the following code snippet. This will give you the flexibility of passing parameters dynamically.

pagereference cl1=new pagereference('/lightning/o/Lead/new');
cl1.getParameters().put('count','1');
cl1.getParameters().put('nooverride','1');
....
cl1.setRedirect(true);
        return cl1;