+ Start a Discussion

Opportunity Product in Lightning - Urgent advice, please

Hi guys,

I am using Lightning and its standard functionality of adding products on an opportunity. I have created a custom field (let's call it X) on the Opportunity Product that it's a Lookup field to a custom object (not ideal)

On the custom object I have created records with name, start date and end date. 

I am looking to pre-populate the start date and end date of the OLI when a value is selected from the custom field with the values from the custom object's records already created.

I have started to create an Apex Class and a trigger, but I have never used Lightning component and I am not sure if it's even possible without a Visualforce Page?

Also, I would like to be able to hide the custom field from the OLI depending on the type of product selected.

It is possible to build this in Lightning Component?

Thanks a lot.
Christian Schwabe 8Christian Schwabe 8
Before coding: My first idea was to realize this requirement with workflow-rule or process. Have you think about that?
This cannot be realized with a QuickAction.

Thanks for coming back to me. I did think of it and I have built it in process builder, for testing; but it only pre-populates the values after save; when the opportunity line item gets created, and I would like it to pre-populate the values when selecting the custom field.

Christian Schwabe 8Christian Schwabe 8
Ah, okay. Now I understand it in a proper way.
This sound like the usage of lightning-record-... (https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.data_get_user_input)
Yes, you could also prepopulate values in the inputfields.