# How to transform data between actions in custom workflow?

**URL:** <https://community.hubspot.com/t/how-to-transform-data-between-actions-in-custom-workflow/61378>\
**Category:** APIs & Integrations\
**Tags:** python, workflows\
**Created:** [July 20, 2022, 6:59pm UTC](https://community.hubspot.com/t/how-to-transform-data-between-actions-in-custom-workflow/61378 "2022-07-20T18:59:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BLai](https://avatars.discourse-cdn.com/v4/letter/b/f05b48/32.png) [@BLai](https://community.hubspot.com/u/BLai)\
**Post date:** [July 20, 2022, 6:59pm UTC](https://community.hubspot.com/t/how-to-transform-data-between-actions-in-custom-workflow/61378/1 "2022-07-20T18:59:56Z")

</div>

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：

 ![BLai_0-1658342103694.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/c/c/ccde51598c15a435145ea585e791be0b94b6ba6e.png)

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:

```lia-code-sample
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:

 ![BLai_2-1658343332319.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/e/ed64d961f086bfc35f817ae9072bff17b561c120.png)

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:

```lia-code-sample
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:

 ![BLai_1-1658343214266.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/c/ca2d7dcd92f6c7d6abcd917fd4fed317ec3aff46.png)

How should I transform the value between Actions?

1. 

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!

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [July 21, 2022, 5:51pm UTC](https://community.hubspot.com/t/how-to-transform-data-between-actions-in-custom-workflow/61378/2 "2022-07-21T17:51:19Z")

</div>

Hi @BLai 👋 Thanks for your question. And for including those details 🙌 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

---

<div class="post-metadata">

**Author:** ![JBeatty](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jbeatty/32/52252_2.png) [@JBeatty](https://community.hubspot.com/u/JBeatty)\
**Post date:** [July 21, 2022, 7:34pm UTC](https://community.hubspot.com/t/how-to-transform-data-between-actions-in-custom-workflow/61378/3 "2022-07-21T19:34:10Z")

</div>

Hi @BLai,

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

 ![JBeatty_0-1658432027223.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/c/c2da26b7641886de7c8fc37ca8fdb778da951613.png)

Best,

---

<div class="post-metadata">

**Author:** ![BLai](https://avatars.discourse-cdn.com/v4/letter/b/f05b48/32.png) [@BLai](https://community.hubspot.com/u/BLai)\
**Post date:** [July 22, 2022, 2:24pm UTC](https://community.hubspot.com/t/how-to-transform-data-between-actions-in-custom-workflow/61378/4 "2022-07-22T14:24:40Z")

</div>

Thanks! That’s the key!
