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.
However, calling sforce.one.createRecord('OpportunityLineItem');
results in a blank "Opportunity" value and clicking in the Product textbox results in an error.
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 (my reputation is too low to post two links, but it's issue id=a1p3A00000186xfQAA
) 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?
Here are the steps to reproduce the issue:
Create the following Visualforce page and enable "Available for Salesforce mobile apps and Lightning Pages"
<apex:page standardController="Opportunity"> <script type="text/javascript"> function createOLI() { sforce.one.createRecord('OpportunityLineItem'); } </script> <div onclick="createOLI();">Create OpportunityLineItem</div> </apex:page>
Add the new Visualforce page to the Opportunity Page Layout
- View an Opportunity
- Click "Create OpportunityLineItem"
You'll see the "Create Opportunity Product" lightbox, but the Opp ID isn't passed in.