+ Start a Discussion
Philip FPhilip F 

How can we add products to an Opportunity using sforce.one.createRecord()?

Following the documentation on navigation with the sforce.one object, I'm attempting to create Opportunity Products with a link on a Visualforce page that has been added to the page layout and is visible in the Details section of the Lightning Experience view of the Opportunity. I'm calling:

sforce.one.createRecord('OpportunityLineItem');

When clicking "Add Product" from the standard Lightning Experience interface, the "Opportunity" value on the lightbox form is pre-populated.

User-added image
However, calling sforce.one.createRecord('OpportunityLineItem'); results in a blank "Opportunity" value and clicking in the Product textbox results in an error.

User-added image

Clearly, calling sforce.one.createRecord('OpportunityLineItem'); isn't providing the Opportunity ID to the Add Product form, but I haven't been able to find any documentation or discussion of how to make this work.

I did find a known issue with Salesforce, that looks like a similar problem.

I know I can create a Visualforce page of my own for adding products, but I'd rather leverage the "Add Product" functionality that already exists in Lightning Experience, if possible. Am I missing something, or are there any pointers you'd recommend?

I've also cross posted this on StackExchange and will report back with anything I learn there.