Salesforce Assets

So as a Salesforce admin and consultant, I have had many conversations regarding Assets in Salesforce. Whether that be as part of your post-sales process e.g. tracking warranties, or part of your service process as a way of providing Entitlements to your customers on certain products that they have purchased. Either way, this little feature can be a key part of your end-to-end sales/service journey. With that in mind, let’s look into how you can create Assets in Salesforce?

Adding Assets in Salesforce

Unfortunately, there is no out of the box automation for Asset creation. But here are 2 declarative ways to add Assets in Salesforce that I would recommend.

1) You can manually add Assets to an Account record. This all depends on volume. If your sales team has enough time on their hands, then this is a totally valid way of adding them. However, bear in mind that if your Account has multiple Opportunities that have lots of products, that have different Entitlements and or warrenties then this process can be cumbersome. My opinion – take this option only if you have a few Closed Won Products that require converting to Assets. 

2) You can use Flow and Process Builder to automatically create Assets. This is a much more involved process which requires a flow that can either be triggered by Process Builder or manually by the user and flow screens. For example, perhaps you have a Closed Won Opportunity that has multiple Opp Line Items (Products), that each requires an Asset record. The Asset needs a start and end date, a serial number, type etc. By creating a flow that loops through all of the Opp line items, you can generate individual Asset records and assign pre-defined field values. This option is much more powerful as it cuts out the admin and allows your team to get on expanding that pipeline. Sounds fab, right!?

But where do I start I hear you say? Not to worry I have the solutioN below. Enjoy creating some badass automation! 

Automating Asset Creation – Flow

Here is a step by step guide to generating Assets via a screen when an Opportunity is Closed-Won. 

This is how your flow should look at the end:

Salesforce Assets

1. Select the Screen element and add a label – this will be what the users see on the record page. Salesforce Assets

a. Add a Display Text from the screen components and insert text.

Salesforce Assets

2. Select the Get Records element. 

a. Add a label

b. Select the Opportunity Object 

c. Here you want to save our Opp id to a variable so that you can reference the fields later on in our flow.

i.In the value box, select +New Resource> Resource Type: Variable>Add API Name>Select Text as the data type. You also want to make the id available outside the flow.

Salesforce Assets

d.The first part should look like this:

Salesforce Assets

e. Next, Select – Only the first record

f. Select Store field values in separate variables.

g. First, you will need to store the Account ID from the Opp – Select AccountId and create a new text variable for reference later.

h. Select the Opp StageName field and add this to a new text variable – OppStageName, for reference later.

Salesforce Assets

The next part is defining a decision as to whether the opp has been closed won or not. In this instance, you do not want the user to be able to create assets on opportunities that have not been closed-won. 

3. Select the Decision element and name it Closed Won Opp?

a. Outcome label – Yes

b. You want to execute when all conditions are met

c. For our condition, you will use the variable – OppStageName that you created in the previous element. So: OppStageName Equals Closed Won 

d. Closed Won is free text and case sensitive. 

e. Leave the default Outcome as is or label to No. 

Salesforce Assets

f. If the Opp has not been closed one, you want the user to know this. To do that, you will add another Screen element here  

g. All a label – Not Closed Won

Salesforce Assets

h. Add a Display Text from the screen components and insert text.

Salesforce Assets

You will now need to get all the Opp line items associated with the Closed Won Opportunity.

4. Select the Get Record element

a. Label: Get Opp Line Item

b. Select Opportunity Product as the object

c. Here you want to make sure the products you are getting belong to the correct opp. Therefore you need to create a condition and get only the record where the Opportunity Id Equals our {!OppId} variable that you created earlier.

Salesforce Assets

d. Next, select Not Ordered 

e. Select All Records for storing

f. You will want to store all those records in a variable so you can use in our flow. To do this click +New Resource in the Record Collection Variable box. 

i. Add an API name

ii. This time you want to save the records to his variable so select Record as the data type.

iii. Select Opportunity Product as the object

Salesforce Assets

iv. Click done and then select the new variable 

v. Next, select the fields you want to store in this variable – for instance, these will be fields you want to integrate further on the flow or in this case, these are the fields you want to use when you create the assets. 

1. ID

2. Description 

3. Product2Id

4. Name

5. Quantity 

6. Created Date

Flow Loop

Once you have got our Opportunity Product Line Items, you will want to loop through them all to assign the fields you got in our Collection variables to the asset record.

5. Select the Loop element > All label “LoopLineItems”

a. Create a Collection Variable

Salesforce Assets

b. Specify the direction for iterating over a collection to ‘First item to last item’

c. Once you have all opp line items, you want to store them in a loop variable – 

d. Create a new Record variable > ass API Name “AllOppLineItems”>Data Type – Record>Object – Opportunity Product

Salesforce Assets

Next, you will want to assign the fields to the Asset record

6. Select the Assignment element. 

a. Add a label 

b. Create a new Asset variable >+New Resource>Api Name “NewAsset”>Data Type – Record>Object – Asset

c. Next, select the variable and field you want to update upon creation of the new asset record. The Values will be the ones you have stored in the variables you have previously created. See screenshot below for an example.

Salesforce Assets

You will now want to Assign those new assets to an all assets variable so that you can create all the records it has looped through and assigned the fields to. 

7. Select the Assignment element.

a. Add a label 

b. Create a new Asset collection variable >+New Resource>Api Name “AllAsset”>Data Type – Record> Select ‘Allow multiple values (collection)  Object – Asset

Salesforce Assets

c. Once created, you will want to add the NewAssets to the AllAsset variable for creation. 

Salesforce Assets

8. Select the Create Record element

a. Add Label – Create Asset Records

b. How many to create – Multiple

c. Select Variable – {!AllAssets}

Salesforce Assets

Create a Confirmation screen to let users know that they have been successfully created.

9. Select the Screen element > Add Label ‘ Assets Created’ > Select Display Text Screen Component

Salesforce Assets

Adding the Flow to a page layout in lightning

For users to have access to the screen flow, you will need to add the flow component to the lightning page. 

1. On the record detail page, click the cog > edit page

a. Select/search Flow from the list of lightning components

Salesforce Assets

b. On the right hand side, select the Asset flow you have just created. 

i. Not showing? Make sure the flow is active!

c. Select – Pass record ID into this variable.

Salesforce Assets

Click Save!

And wallah! All Salesforce assets should now be created.

Top tip. The debug option in Flow is AMAZING. Therefore, I would suggest using this feature before activating your flow. That way it will let me know if the flow works, and if not, why? Cheers!

Happy Asset creating folks. 

Jenny Bamber October 21, 2019

Leave a Reply

Your email address will not be published. Required fields are marked *