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
Siddharth PrakashSiddharth Prakash 

Prepopulate Opportunity Line Item Fields On Creation Page

Hi guys,

We have an issue where we need to pre-populate the two dates from the opportunity page to the opportunity line item creation page. The pre-population is necessary and this needs to be done on page load and not on page submission. 
How do we go about executing this? 

Regards
Siddharth
Sagar PareekSagar Pareek
You can create a custom button which will have values in parameter and on load of the page your can pre-populate those values using jquery/javaScript into the fields(s) on next page. 
Siddharth PrakashSiddharth Prakash
Hi Sagar,

I am not able to add custom button on the Selectsearch page. First we have the Add Product page , after that we have the select search page , where there is no option to add custom button.
Page - cs16.salesforce.com/p/opp/SelectSearch

This is not customizable. I am not able to see anything where we can customize this. Do you know any other way.
I know it has to be done on click of "Select" button and then pass the opportunity page value (of the dates) into a specific field value so that it is set in the next page - when it loads.

Regards
Siddharth
James LoghryJames Loghry
You can override the "Add Product" button with a Visualforce page and a custom extension class. The visualforce page would need to use the Opportunity Product as a standard controller, and an Apex extension class.  In your extension class, you would requery the Opportunity for the date you're looking at, and then set the Opportunity line item's date to that value.

Otherwise, you could default the Opportunity Product's date field using either a trigger or a workflow rule + field update.
V R 9V R 9
Could you use a headless flow to add the field and store it in a variable?
Siddharth PrakashSiddharth Prakash
Hi VR 9,

Headless flow ? Could you please elaborate on that a bit ?

Regards
Siddharth