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
Yeshi Mohammed 9Yeshi Mohammed 9 

create new opportunity from contact - using Opportunity custom button

Hello All,
I have Opportunity custom button called "Create New Opportuniy" to create new opportunity from Contact. we also associate the Contact as opportunity Contact Role

Here is the code 
(/setup/ui/recordtypeselect.jsp?ent=Opportunity
&retURL=/006/o
&save_new_url=%2F006%2Fe%3FretURL%3D{!Contact.Id}%26ent%3DOpportunityaccid%3D{!Account.Id}%26conid%3D{!Contact.Id}%2600N400000029iiN%3D{!Contact.Lead_Source_Detail__c}%26opp6%3D{!Contact.LeadSource}%26opp3%3D{!Account.Name}%2B-%26nooverride%3D1)

This code works fine for Salesforce Classic users. But since we have Classic and lightning users, when a user in lightning clicks on this button the default setup such as  AccountId , ContactID, LeadSource, AccountName ... does not get passed. this leads to Opportunity Contact Role not being Created. How Can I make a code that works for both Classic and lightning. any help will be appreciated. 
Thank you 
-Yeshi 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Yeshi,

Can you please check the below article. I hope this will help you on this.

https://marktyrrell.com/posts/alternatives-to-custom-button-url-hacks-for-lightning-experience/

If this solution helps, Please mark it as best answer.

Thanks,