APIs & Integrations

Mahe
Participant

Extracting deal id from "Create Record" action in workflow

SOLVE

Hi,

I am trying to create a workflow which, when a deal is renewed, creates a new deal, and then adds line items. I have made the custom code extracting the line item information from the original deal, and then i have added an action called "Create Record" in which i copy the different properties form the original deal to the new deal.

My problem is, when creating the custom code for the new line items on the deal created by the action, that i do not have the deal ID of the new deal. 

Mahe_0-1708518129265.png

My flow looks like this, and my custom code for creating the new line item works, if i manually type in a deal ID, but i would like for the custom code to have the deal ID from the newly created deal.

Hope my explenation makes sence .... 

0 Upvotes
1 Accepted solution
Josh
Solution
Recognized Expert | Platinum Partner
Recognized Expert | Platinum Partner

Extracting deal id from "Create Record" action in workflow

SOLVE

Hi @Mahe,

 

Your deal ID won't exist until your deal is actually created. I would suggest either adding a delay to allow the deal to create and then extracting the ID or kick it over to another workflow to complete your actions, pulling the newly created deal id from there. I would probably do the latter in my opinion. 




Did this post help solve your problem? If so, please mark it as a solution.

Josh Curcio

HubSpot support and inbound marketing for OEMs, contract manufacturers, and industrial suppliers.
HubSpot Platinum Partner & HubSpot Certified Trainer

View solution in original post

2 Replies 2
JTBuys
Contributor | Platinum Partner
Contributor | Platinum Partner

Extracting deal id from "Create Record" action in workflow

SOLVE

I agree with @Josh, I would use two workflows. One workflow for creating the new deal and associating to the last deal, and a second workflow for grabbing the line items from the associated, last deal and adding them to the renewal deal. By using a second workflow you allow your CCAs to easily use the renewal deal record id.

You will need to have deal-to-deal assocaition configured and ensure that the new deal is associated when it's created.

Screenshot 2024-02-21 at 9.06.39 AM.png

 

Then you can use a second workflow that enrolls the renewal deal to retrieves the line items of the last deal and adds them to the currently enrolled renewal deal. You can use something like below to get the associated deal.

 

const DealAssociationBatchInput = { inputs: [{"id":event.object.objectId}] };

hubspotClient.crm.associations.v4.batchApi.getPage("deals", "deals", DealAssociationBatchInput)

 


Alternatively, if you do not wish to use a second workflow, you could use a CCA to create the new deal through the API rather than the standard create record action. The api response will return the newly created deal's record id.

0 Upvotes
Josh
Solution
Recognized Expert | Platinum Partner
Recognized Expert | Platinum Partner

Extracting deal id from "Create Record" action in workflow

SOLVE

Hi @Mahe,

 

Your deal ID won't exist until your deal is actually created. I would suggest either adding a delay to allow the deal to create and then extracting the ID or kick it over to another workflow to complete your actions, pulling the newly created deal id from there. I would probably do the latter in my opinion. 




Did this post help solve your problem? If so, please mark it as a solution.

Josh Curcio

HubSpot support and inbound marketing for OEMs, contract manufacturers, and industrial suppliers.
HubSpot Platinum Partner & HubSpot Certified Trainer