Consolidate Opportunity Product Text fields into Opportunity Text fields

Some features

  • Semicolon-separate the values from all the records into one text field

  • Fill as many fields as you want

  • Source fields can be concatenated formula fields!

  • You can fill a full value into a long text field and a shorter, product code style value into a short text field which you can use for REPORT CRITERIA, FORMULA FIELDS and WORKFLOW RULES.

Semicolon-separated, just like multi-select fields

Target Short Text Fields, Long Text Fields, or Multi-select Picklist Fields

Use Formula Fields to Concatenate

We built an app for that — and you can have the code!

This has been one of the most populate pages on our website because there are so many great uses for an application like this.

We decided to release this as a free application and also give you the code.

We’ll be making updates to the application in the future — specifically adding more flexibility, an Admin UI, and asynchronous options that can produce retroactive data.

Until then, please enjoy these and the following instructions for managing the application:

Install Oppty Product Summarizer in Production

 

 

Install Oppty Product Summarizer in Sandbox

 

 

 

Here is the source code, including test classes that may or may not pass in your org.

 

Instructions for using the app:

BROAD STROKES:

1) Install the Opportunity Line Item summarizer Application

2) Activate it and set the “Run all Opps Thru Trigger”
3) Use Apex Data Loader to update the Opportunity Products from Opportunities you want summarized (test with 50 first)
4) Change the settings of the application for ongoing use

 

Details:

1) Install the application:
https://login.salesforce.com/packaging/installPackage.apexp?p0=04tf2000000XihU

Install for Admins Only
(it’s an automation application that non-admins do not need to access)

2) Activate it and set the “Run all Opps Thru Trigger”

A) In salesforce, go to Setup -> Search for “Custom Settings” -> Click Custom Settings

B) Now click on “Magic Robot OLI App Settings”:

C) Create new Default level settings:

D) Set true (Checked) for:
– Activate Application
– Run all Opps Thru Update? (this setting simply means that when you update Opportunity Line Items, it will send the values to the opportunity regardless of the ProductCode field changing or not)

Save the Settings.

Once you save, the application will be active so any edits, inserts or deletes of Opportunity Products will mean your Opportunities’ fields will get updated.

3) Use Apex Data Loader to update the Opportunity Products from Opportunities you want summarized (test with 10 or 50 first just to make sure nothing bad happens)

A) Deactivate any workflow rules or process builders on the Opportunity that will email anyone or do any major cross-object updates

B) Export the report of Opportunity Products (Line Items) to CSV. The only column you need is the 18-character id (but you can keep whatever you want.

C) Use Apex Data Loader to run an update on all the Opportunity Products in your spreadsheet:

i) Open Data Loader
ii) choose “Update”
iii) Login
iv) Now select “Show all Salesforce Objects” & “Opportunity Product”

v) select your CSV file of Opportunity Products
vi) Map the Record Id field to the column of the record id in your CSV file (you only need to map the “id” field)
vii) click next & finish

… now Data Loader will be updating the Opportunity Products, which will get caught by the Magic Robot trigger and will update the two fields on your Opportunity with the Product Codes list. Wait for that to finish.

4) Once Data Loader is finished and all your opportunities are set, you should now change the settings to this for ongoing use by your end users:

Checking the box for “Use At-Future to update Opps?” will be a better user experience for your end users in that the processing to update the Opportunities will happen asynchronously. So when they update or create or delete Opportunity Products, the automation to update the Opportunities will happen a few milliseconds later when the system has resources, and if there are any problems updating or other automation is run because the Opportunity is updated, the end users will not be waiting for the page to refresh. However, this also means that the product codes may not be instantaneously on the Opportunity.

Also, any time you make mass updates, you will want this setting OFF because running too many records through that at-future framework (e.g. more than a few hundred) can jam up salesforce’s asynchronous queues.

5) OTHER NOTES ABOUT THE APP:

I wrote the automation to automatically try to update Product Codes onto your two custom fields if the org doesn’t have any settings set. No other orgs will have these exact named fields so nothing will happen. However, you can use this application to string out any Opportunity Text field values to any Opportunity Text field (and future enhancements will expand capabilities and the admin UX).

Today, you could use the Custom Settings “Magic Robot OLI: Line to Parent Mapping” to specify how you want it to work:

Specifically to represent what you have, we would “Manage” / Create two “Magic Robot OLI: Line to Parent Mapping” records that look like this:

Last but not least, if there are ever problems with the trigger throwing exceptions for the reps, you can always disable it using the App Settings, like this: