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
Carolin HeynCarolin Heyn 

Copy custom Opportunity Products to Quote Line Items

Hi everyone,

I want to use quotes in my org but as we use a custom object for opportuity Line Items the Information will not gon into the new Quote Line Item. Any suggestion how I can copy the custom Object into the QuoteLineItems? 

Many thanks. 
Khan AnasKhan Anas (Salesforce Developers) 
Hi Carolin,

Greetings to you!

Please refer to the below links which might help you further with the above requirement.

I hope it helps you.

https://douglascayers.com/2017/03/25/copy-opportunity-line-item-custom-fields-to-new-quote-line-items/

https://success.salesforce.com/answers?id=90630000000D9XMAA0

https://success.salesforce.com/answers?id=9063A000000pPXCQA2

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Carolin HeynCarolin Heyn
HI Khan, not sure if this will work in any way because i am not using the standard opportunity line items.

BR Carolin 
KrishnaAvvaKrishnaAvva
Hi Carolin,

Please write an after insert trigger on Quote, which will copy the respective Opportunity Line Items from the Opportunity to Quoute Line Items of the quote.

Regards,
Krishna Avva
Dustin NordquistDustin Nordquist
You can also do this in Flows with a record update that sets your Custom_Field__c equal to {!$Record.OpportunityLineItem.Custom_Field__c}

Reference: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_opportunitylineitem.htm
Dan LeBlanc 4Dan LeBlanc 4
Hi. This issue has been a thorn in my company's side for quite some time with no solution in site. The suggestion of using the package provided here: https://appexchange.salesforce.com/appxListingDetail?listingId=a0N30000003Iop5EAC&tab=d is not valid as the syncing only works from the quote to the opportunity, not vice versa. If it did sync the other way, it hasn't for quite some time.

There has been talk about using the opportunity line to identify and update the quote lines but debates of that link/relationship existing has gone back and forth. Without needing to create custom apex code, etc. to accomplish this, I decided to export a sample row from the QuoteLineItems table to see what I was dealing with. I discovered the same reference above but I'll help by explaining how to do it in flows, not in triggers and apex.

I created two different flows;
  • one to set my custom field in the Quote Line Item with the value in the custom field of the related Opportunity Product Line
  • another to set my custom field in the opportunity product line with the value from the custom field in the quote line item
I chose to perform these actions in two separate flows in order to maintain a semblance of organization.

QuoteLineItem Record Triggered Flow
  • Upon creation or update
  • Fast Field Update
  • No entry conditions
  • First (and only) flow item is an Update Records action that, using the "quote line item record that triggered the flow" to set my "Unit" field to {!$Record.OpportunityLineItem.Unit__c}
When a quote line item is created or updated, it will identify what the value of my custom field "unit" is and copy it to the line

OpportunityProduct Record Triggered Flow
  • Upon creation or update
  • Actions and Related Records
  • No entry conditions
  • First (and only) flow item is an Update Records action that, using the "Specify conditions to identify records,and set fields individually"as follows:
    • Object: Quote Line Item
    • Condition(s): OpportunityLineItemID = {!$Record.Id} AND QuoteId = {!$Record.Opportunity.SyncedQuoteId} (this way it only updates the synced quote, not all related quotes), in case you have quotes with different values related, you'd hate to update those if you didn't intend to
    • Field: Unit, set to {!$Record.Unit__c}
I've tested this and it works. My scenario is as follows in case it may not be best suited for your own:
  • Using the standard quote object (no CPQ purchased, etc)
  • Updating only the synced quote line items, not all related quotes (although if you wanted all quotes to update, you could remove that synced quote condition above and accomplish that)
My team's workflow is as follows:
  1. Create a new opportunity
  2. Add line items to that opportunity
  3. Create a quote for that opportunity
    1. (quote lines get added automatically from the opp, excluding any custom fields)
    2. My 2nd flow above triggers and sets the "unit" field to that of the opportunity "unit" field
  4. Start Sync is clicked, thereby syncing any standard fields back to the opportunity from the quote
    1. My 1st flow above triggers and sets the "unit" field to that of the quote "unit" field value. (I could add criteria to only update if it is different to avoid multiple hits to the record, but we aren't that large of a company to worry about it)
The above should also work if you were not syncing back to the Opportunity yet, for example if you created 3 different quotes, each with different values. You would have them generated all with the "unit" field from the opp line, then you could modify each to your own needs and present to the customer. Upon accepting option 1, 2, or 3, you would sync that quote back to the opp and set the opportunity line items/values/fields to that of the synced quote.

I've been looking for a solution for this for a while and feel this accomplishes it. If anyone has any questions, feel free to ask but I felt good about getting here using out-of-the-box features in SFDC without needing to use Apex triggers and code or install 3rd party tools, until SFDC manages this in house.