Copy Opportunity Line Item Custom Fields to New Quote Line Items

salesforce-opportunity-quotes.png

At the time of this project, when a Quote is created from the Salesforce UI (Classic or Lightning), or the Quote is syncing, and you create an OpportunityLineItem (that is, add an Opportunity Product via the Products related list) then Salesforce automatically copies and syncs the OpportunityLineItem standard fields to the QuoteLineItem standard fields.

Custom fields are ignored.

This project allows you to define via custom setting which OpportunityLineItem custom fields you want copied down to the newly created QuoteLineItem custom fields.

Please note that this project currently does not handle syncing. I explain why in more detail on the project’s FAQ. In short, it’s a really hard problem to get right and not risk data corruption. Users aren’t happy when you corrupt their data.

This solution, openly available on GitHub, uses a Custom Setting to let you configure which fields you want copied from the OpportunityLineItem to the QuoteLineItem. Since standard fields are already handled by Salesforce automatically then you only need to configure custom fields in the custom setting mapping.

In the below screen shots I show an example where I’ve created custom fields on both the OpportunityLineItem and QuoteLineItem named Warranty__c. I use the custom setting to indicate that I want to map the two fields together (conceptually like Lead Field Mapping from Lead to Account).

quote-line-item-field-mapping-custom-setting1.png

On my opportunity, I added two products and populated the Warranty custom field.

opportunity-line-items1.png

then created a new quote. Automatically, Salesforce creates QuoteLineItems based on the OpportunityLineItems of the parent opportunity, and it copies all the standard field values. My solution takes this a step further and ensures the custom fields are populated too. Without my trigger then the QuoteLineItem.Warranty__c field would still be blank.

quote-line-items1.png

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s