How to transform data between actions in custom workflow?

Hello Team,

I am new to HubSpots and I am working on custom workflow. I have 2 confusions while coding:

1.How can I transform data between differnet actions?

The workflow I am building look like this:

In the first action, I get and return phone number of all the enrolled contacts. The first action should be fine since it has passed the test.

Here’s my code:

import os
import hubspot as HubSpot
from hubspot.crm.contacts import ApiException, SimplePublicObjectInput

def main(event):

 hubspot = HubSpot.Client.create(api_key="my api key")

 phone = ''
 try:
 ApiResponse = hubspot.crm.contacts.basic_api.get_by_id(event.get('object').get('objectId'), properties=["phone","hs_object_id"])
 contact_id = ApiResponse.properties.get('hs_object_id')
 phone = ApiResponse.properties.get('phone')
 except ApiException as e:
 print(e)
 raise

 return {
 "outputFields": {
 "contact_id": contact_id,
 "phone": phone
 }
 }

The data outputs is set like this:

Then I want to transform the returned value to next action. I am not sure how to do that. I tried to follow the guide but still failed. Here’s my code of the second Action and test result:

import os
from hubspot import HubSpot
from hubspot.crm.contacts import ApiException, SimplePublicObjectInput

def main(event):

 phone = event.get('inputFields').get('phone')

 return {
 "outputFields": {
 "phone": phone
 }
 }

And the result looks like this:

How should I transform the value between Actions?

And in the next step I will try to transform the data between workflow. Can they work in the similar logic?

Thanks for the help!

Hi @BLai :waving_hand: Thanks for your question. And for including those details :raising_hands: Let’s see if we can help get the conversation started.

Hey, @Teun @taran42 @JBeatty, do you have any suggestions for @BLai or tips on what they could provide the community to help understand their issue?

Thank you very much! — Jaycee

Hi @BLai,

Did you make sure to include the output of your first custom code block into the second custom code block?

Best,

Thanks! That’s the key!