× Home Blog About Us
Products SimpleImport AddressTools PhoneTools IndustryComplete
Partners Support Careers Contact

Blog

 
Blog > Post

How to simplify importing Opportunity Products in Salesforce using Managed Import

by Abdullah Rana SimpleImport

Importing Opportunity Products (OpportunityLineItem)

After reading this article, you’ll be able to:

  • Identify the advantages of using Managed Import to import Opportunity Products.
  • Create an object and field mapping in SimpleImport for Opportunity Products.
  • Add and configure the Managed Import component to an Opportunity Record Page.
  • Test Managed Import.

Why use Managed Import to import Opportunity Products?

Managed Import, part of SimpleImport Premium, optimizes importing Opportunity Products to Opportunities within your Salesforce organization by allowing you to upload the file on the Opportunity record page itself. The solution then does all the hard work for you - there’s no need to map fields every time, or source record IDs. This not only saves you time, it also prevents user error.

It requires a one-time setup that then allows users to rinse and repeat, time and time again, saving on average over two minutes for every file imported.

Like the sound of Managed Import? Get in contact with us and we’d love to show you around SimpleImport. If you’ve already got SimpleImport, keep reading!

Longversion

Create an object and field mapping

The following steps assume that you have active Products with Price Book Entries. Also, the Opportunities we will use in this example will already have a Price Book selected.

Before the component can be placed onto any Lightning page, it requires a pre-defined mapping which contains reference to the object and fields that the user will be importing into. Using SimpleImport Premium, this process is made effortless.

As we’ll be importing Opportunity Line Items, let’s take a look at this object in more detail. This will help us create a mapping.

The object has four mandatory fields so these must be configured in our mapping. Here’s a handy description of what data should be fed into these fields:

  • Opportunity - the Opportunity record that the product will be associated with.
  • Product - the Product that will be added. This can be an ID, or Product Name if they are unique in your Org.
  • Quantity - the quantity of the Product being added to the Opportunity.
  • Sales Price - the price of the Product, per item.

Note: Total Price on the Opportunity Line Item record is a calculation of Quantity x Sales Price and is processed automatically during upsert.

Now we know what fields are required, let’s create a template file which we will use to create a mapping. To create a mapping, the file must contain field names in row 1 and at least one row of import data in row 2.


Create a template file

  1. Create a new spreadsheet file and populate row 1 with each of the four mandatory fields noted above.
  2. In the first cell underneath Opportunity, add the {!Record.Id} tag.
  3. In the first cell underneath Product, add either the Product Name or ID. This product must be Active and have a Price Book associated with it.
  4. In the first cell underneath Quantity, enter a value.
  5. In the first cell underneath Sales Price, enter a value.
  6. Save the file to your computer.
Screenshot 2021 03 29 at 17.13.47

Generate a mapping

Now that we have a template file, we need to configure the file within SimpleImport and generate a mapping.

  1. From the App Launcher, find and select SimpleImport.
  2. Upload the created template file by using either the drag & drop functionality or click to upload.
  3. Once the file has uploaded, select the Import to Salesforce button.
  4. In the Object Selection master picklist, choose Opportunity Product (OpportunityLineItem).
  5. Click Continue.

The field mapping page now allows us to choose the destination fields on the Opportunity Line Item object. Selecting the edit icon on each row under the Object fields section will open the field finder. Each field in the field finder will be structured in the following way:

Field Name | External ID Field (if applicable) | Object

  1. For Opportunity, map Opportunity ID (OpportunityId) | Opportunity ID (Id) | OpportunityLineItem.
  2. For Product, map Product ID (ProductId2) | Product Name (Name) | OpportunityLineItem.
  3. For Quantity, map Quantity (Quantity) | OpportunityLineItem.
  4. For Sales Price, map Sales Price (UnitPrice) | OpportunityLineItem.
  5. Now that the mapping is correctly configured, use the Save Mapping button and name the mapping.

Note: If you are using a Product ID to reference products in your import, use Product ID (ProductId2) | Product ID (Id) | OpportunityLineItem instead.

Screenshot 2021 03 30 at 13.37.16

With the mapping saved, we must now activate it and locate the ID for use with the Managed Import component. Use the Preferences button at the top of the page and scroll down to the Mapping List section to locate the mapping you saved.

Select Create Custom Setting in the action column to activate it. A confirmation will appear once the custom setting has been created successfully.

If you are using Managed Import for Communities, you will have to manually create the custom setting by following the instructions provided in the Setup Guide on the AppExchange listing and sent via email.

Make note of the Mapping ID found in the second column as this will be used in a moment.

Screenshot 2021 03 29 at 17.27.27

Add the Managed Import component to your page

With a mapping now activated, we want to place the Managed Import component onto the Opportunity Record Page so that our users can import their products whilst looking at the Opportunity.

In Salesforce, navigate to Setup and select Lightning App Builder from the setup menu.

Screenshot 2021 03 25 at 23.53.44

If you already have a custom Lightning Page for your Opportunity, select Edit next to it. Alternatively, select New and follow the steps through to create a new record page. This org already has one created so we will edit Opportunity Record Page.

Screenshot 2021 03 25 at 23.54.10

From the Components menu on the left of the screen, search Managed Import and drag it onto your layout. You will initially see that ‘Managed Import is invalid’ but this will change with later configuration.

If you can’t see Managed Import from the list, check that you have My Domain enabled and deployed to your users.

Screenshot 2021 03 25 at 23.57.16

Once the component has been placed, click on it. The design parameters menu will appear on the right of the screen. In the Mapping ID field, enter the Mapping ID captured in the previous section.

You can edit the button and title text to meet your requirements and a text area is provided to add any comments to the component.

Now, remember when we used the {!Record.Id} tag in our file? We want to tick the ‘Pass current record ID into this import’ box which enables passing the current page’s record ID to the job which is then used in the {!Record.Id} tags in the file. This is how we associate the products with the Opportunity record that the user is currently viewing. It removes the requirement for the user to copy a record ID into the file every time they want to add related records to an existing opportunity. In short, this will save users time and prevent user error!

Find out more about using the record ID tag here.

Managed Import Opportunity Products

Press Save and Activate to confirm your changes to the page layout and now it’s ready go!

Adding import to page save activation 6 w800px

Testing out the Managed Import component

If you’re this far, well done! We’ll now need to test the component to make sure it works as expected.

Go to an Opportunity record where you want to import the Opportunity Line Items. If you don’t see the component, you may be required to clear your browser’s cache before it becomes visible.

Click the button in the component to open up the Managed Import modal.

Overview

Use the Upload File button or drag the file for importing into the modal.

Screenshot 2021 03 26 at 00.07.21

Managed Import will now go to work processing the file and extracting the data to insert it into your organisation. You can follow the progress via the path available at the top of the window.

Once the path hits Finished, you should see the summary in the component such as Inserted 5 Opportunity Product.

To review the successful rows, use the drop down action and select Download success file.

If errors are generated during the import operation due to validation rules or Salesforce exceptions, use the drop down action to reveal a Download error file option. This will produce a CSV highlighting the failed rows. A new column will be provided stating the Salesforce exception which resulted in the failed attempt. Once these errors have been rectified in your Salesforce environment, you can try again.

Screenshot 2021 03 30 at 13.41.40

For the final check, close the Managed Import modal and review Products in the Related section on the Opportunity. You will see the inserted products and sale price of any Opportunity Line Item file that was imported.

Screenshot 2021 03 31 at 19.10.14

And that’s it! You can use the component over and over on each of your Opportunities without any need to remap any fields. When you’re ready to deploy the component to your users, be sure to check out our How to: deploy SimpleImport and Managed Import to users in your organization.

Still have questions?

Contact us via email and our team will be more than happy to answer any queries: support@provenworks.com