[SalesForce] Automatically Linking Opportunity Product to Asset in Process Builder

I'm trying to create a process linking multiple Opportunity Products to an Asset, So that we can use it to know which products are part of what Asset.

So far, this endeavour has multiple steps involved:

1.Automatically creating the Opportunity Products from the Primary Quote (this works);

2.Automatically creating the Asset upon Opportunity Closed Won (this works);

3.Automatically creating the link between Opportunity Products and Asset (this doesn't work).

I created the lookup field on the Opportunity Product, and if I put the Asset in manually it works. But now I want to automate it.
The missing link seems to be the path i should assign the process builder.

I've included screenshots for you guys to better understand what I'm talking about.

So here is what the process looks like :enter image description here

And here's the issue : I can't seem to find the correct pathway to reference the Asset record related to the Opportunity.

This is as close as I got : enter image description here

However, when I run the process it gives me the following error : enter image description here

Does anyone know how I could reference the Asset record I just created in the 1st part of the process to the Asset field on my Opportunity Product?

Best Answer

The problem is that the Asset won't be linked to the opportunity when you use the Create a Record action, so you'll need one of four alternatives.

First, you could create a lookup on the Asset to link it to the Opportunity. Then, you'd have a second Process on the Asset to complete linking the records. If this sounds unnecessarily complicated, you're right, but it's the only way to do this that I'm aware of without putting additional moving parts in play.

Second, you could create a Flow that is called instead of the Create a Record action. From there, you will have the ability to set variables so that you know what Asset you just created, allowing you to complete the process of linking the records together.

Third, you could just create an Invocable Method. This means you'll have to write and deploy Apex Code, but at least it would be relatively painless compared to trying to build this in the UI. However, if you've already gotten as far as considering this option, then...

Fourth, you could just write a trigger. Process Builder isn't well-suited for things like multi-level record creation. It's a simple tool that allows you to create trivial inserts and updates, but this kind of use case is where the limitations become pretty obvious.

Related Topic