Ask Search:
Surendra PeramSurendra Peram 

Lightning : Open a VF page from custom detail button

Hi,

My Existin functionality in Classic is
Created URL detail button to open the VF page with perameters.
Like:
/apex/SampleVFPage001?selectedRecordId={!opportunity.Id}
&"&appName=Sample App"

My requirement: 
I need to implement the same URL button with VF page in Lightning, 
Please suggest me how to do this

Thanks,
Surendra

 
Best Answer chosen by Surendra Peram
Subhendu VermaSubhendu Verma
Hi Surendra,
You can use URLFOR() function in the content source URL of your detail page button. The URLFOR() function will create the URI as per user's salesforce theme to load the target page. So the same button will work in Classic and Lightning as well. If you wish to add fields from the object, then you will have to create URL by concatnating strings and field values. Try below content source URL in your URL detail button to open the VF page with parameters.
{!URLFOR( '/apex/SampleVFPage001?selectedRecordId=' & Opportunity.Id & '&appName=Sample App')}
You will need to add the button in Button section of Page layout for Classic mode. And for lightning, you will have to add the same button on "Salesforce Mobile and Lightning Experience Actions" section. 

Please let us know if this works.

Thanks,
Subhendu

All Answers

Amit SinghAmit Singh
Hi Surendra,

You can add the same button in "Salesforce Mobile and Lightning Experience Actions" Section.

Edit Opportunity Layout and add the button "Salesforce Mobile and Lightning Experience Actions" section.

User-added image
Surendra PeramSurendra Peram
Amit, thanks for your reply

i am done for adding button, but i am getting error regarding parameters related,
Error is like perameters missing

Can you please frame the URL and post here
 
Subhendu VermaSubhendu Verma
Hi Surendra,
You can use URLFOR() function in the content source URL of your detail page button. The URLFOR() function will create the URI as per user's salesforce theme to load the target page. So the same button will work in Classic and Lightning as well. If you wish to add fields from the object, then you will have to create URL by concatnating strings and field values. Try below content source URL in your URL detail button to open the VF page with parameters.
{!URLFOR( '/apex/SampleVFPage001?selectedRecordId=' & Opportunity.Id & '&appName=Sample App')}
You will need to add the button in Button section of Page layout for Classic mode. And for lightning, you will have to add the same button on "Salesforce Mobile and Lightning Experience Actions" section. 

Please let us know if this works.

Thanks,
Subhendu
This was selected as the best answer