• Help Desk reporting gives you real-time visibility into your support operation without the manual work. Ask our experts about which metrics matter most! AMA Dec 8-12.

    Ask us anything

Custom Coded Wkflw Action - UserID Output

JLittle2
Contributor

I've sucessfully written code to pull the userid of the person who made the change to the property that triggers my workflow, but now I'm struggling to get that userid to be set as the lead owner.

 

I'm currently setting the UserId output as a 'number'. When I try to use action output in an edit record action (to fill the lead owner) the option is greyed out and says that the action output is not compatible. I tried outputting as a string as well.

 

Is there a way to translate a custom coded action output to a userID? Or, is there a way to use the last CCA's output as an input in another custom coded action, so I can write some code to update the lead owner?

 

Thanks y'all.

0 Upvotes
1 Accepted solution
JLittle2
Solution
Contributor

Turns out there are two different user identifiers in hubspot - UserID and hubspot_owner_id. Since property change history records UserID, not the owner id, I had to use the userID to find owner id.

 

I first tried using a search post request (https://developers.hubspot.com/docs/guides/api/crm/search) but apparently it isn't available with the owners object. So intstead I had to create code that pulls all the owners, searches for the correct userID, and finds the hubspot_owner_id of that userID - then updates the lead owner using the hubspot_owner_id. 

 

here's my first set of code for pulling the userID of the property change instigator (the property create_lead is how my workflow is triggered, so I didn't need to check for a specific value that it was changed to):
Retrieve Property Change Instigator userIDRetrieve Property Change Instigator userID

 

Here's my code to search owners to find the correct userID, and set the lead owner:

pull hubspot_owner_id using userID, update lead ownerpull hubspot_owner_id using userID, update lead owner

 

Hopefully this helps someone(:

View solution in original post

0 Upvotes
2 Replies 2
JLittle2
Solution
Contributor

Turns out there are two different user identifiers in hubspot - UserID and hubspot_owner_id. Since property change history records UserID, not the owner id, I had to use the userID to find owner id.

 

I first tried using a search post request (https://developers.hubspot.com/docs/guides/api/crm/search) but apparently it isn't available with the owners object. So intstead I had to create code that pulls all the owners, searches for the correct userID, and finds the hubspot_owner_id of that userID - then updates the lead owner using the hubspot_owner_id. 

 

here's my first set of code for pulling the userID of the property change instigator (the property create_lead is how my workflow is triggered, so I didn't need to check for a specific value that it was changed to):
Retrieve Property Change Instigator userIDRetrieve Property Change Instigator userID

 

Here's my code to search owners to find the correct userID, and set the lead owner:

pull hubspot_owner_id using userID, update lead ownerpull hubspot_owner_id using userID, update lead owner

 

Hopefully this helps someone(:

0 Upvotes
Jaycee_Lewis
Thought Leader

Hey, @JLittle2 👋 Can you share your code? Along with screenshots of how the action is set up? It's hard to say anything for sure without testing a bit. 

 

Thanks! — Jaycee





loop


Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.

Learn More




0 Upvotes