In Salesforce Classic, you can create a new opportunity using a URL like the below:


This works great, creates the opportunity, and creates an Opportunity Contact Role using the contact id passed in.

In our org we override the "New" opportunity button in order to do some validation before we allow users to create an opportunity, and use the url parameter so that the standard screen will also create the opp contact role.

In LEX, we've converted that validation into a Lightning Action where we pass the user on to the standard opportunity Create Record. All works great, but the Opp Contact Role is not created automatically.

Is there an equivalent to the url hack used in Classic, in LEX?

1 Answer 1


I don't believe there's any equivalent to the Classic URL hack. This behavior is something you can automate, though, without writing any code.

Add a new lookup on Opportunity to Contact; call it Primary_Contact__c, for example. Make sure, in your Quick Action on the Contact object, that that field is selected as the "Relationship Name". (Note that if there's only one relationship field between Contact and Opportunity, you won't get to choose - that field will be selected automatically).

Now, build a new Process. Set it to run on Opportunity creation only, with a single criteria node that looks for Primary_Contact__c to not be blank.

Add an action to the criteria node to create a record, and configure it to create an Opportunity Contact Role using the Opportunity Id, the value of the Primary_Contact__c field, and whatever Role your organization prefers.

Then your Quick Action should exhibit that same behavior you expect.

  • thanks for the confirmation on this. Lot's of trigger code and process builders around Opportunities and Opportunity Contact Roles already in this org. Was hoping not to have to untangle those, but here we go!
    – JasonS
    Nov 29, 2018 at 16:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .