APIs & Integrations

BLai
Participant

How to transform data between actions in custom workflow?

SOLVE

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

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:

BLai_2-1658343332319.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:

 

 

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

 

How should I transform the value between Actions?

 

2.

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! 

 

0 Upvotes
1 Accepted solution
JBeatty
Solution
Guide | Diamond Partner
Guide | Diamond Partner

How to transform data between actions in custom workflow?

SOLVE

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

 

Best,

✔️ Was I able to help answer your question? Help the community by marking it as a solution.

Joshua Beatty
Software Developer with Pearagon

Still have questions? Let's Talk

View solution in original post

3 Replies 3
JBeatty
Solution
Guide | Diamond Partner
Guide | Diamond Partner

How to transform data between actions in custom workflow?

SOLVE

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

 

Best,

✔️ Was I able to help answer your question? Help the community by marking it as a solution.

Joshua Beatty
Software Developer with Pearagon

Still have questions? Let's Talk

BLai
Participant

How to transform data between actions in custom workflow?

SOLVE

Thanks! That's the key!

Jaycee_Lewis
Community Manager
Community Manager

How to transform data between actions in custom workflow?

SOLVE

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

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes