APIs & Integrations

MTonmoy9
Member

Custom workflow action

Hello,
I'm trying to create custom workflow action. I need to send enrolled records "hs_object_id" and internal value of a selected input property "propertyName". I'm attaching the payload that I'm sending via postman. Can anyone please guide me here how I can send those data to the endpoint.
Thanks


```
{
"actionUrl": "**",
"objectTypes":[
"CONTACT"
],
"published": true,
"inputFields": [
{
"typeDefinition": {
"name": "Phone_Number",
"type": "string",
"fieldType": "text"
},
"supportedValueTypes": [
"STATIC_VALUE"
],
"isRequired": true
},
{
"typeDefinition": {
"name": "country",
"type": "string",
"fieldType": "text"
},
"supportedValueTypes": [
"STATIC_VALUE"
],
"isRequired": false
},
{
"typeDefinition": {
"name": "propertyName",
"type": "object_coordinates",
"fieldType": "text"
},
"supportedValueTypes": [
"OBJECT_PROPERTY"
],
"isRequired": false
}
],
"outputFields": [
{
"typeDefinition": {
"name": "quality",
"type": "string",
"fieldType": "text"
},
"supportedValueTypes": [
"STATIC_VALUE"
]
},
{
"typeDefinition": {
"name": "message",
"type": "string",
"fieldType": "text"
},
"supportedValueTypes": [
"STATIC_VALUE"
]
}
],
"labels": {
"en": {
"actionName": "Check Phone Number",
"inputFieldLabels": {
"Phone_Number": "Phone Number*",
"country": "Country (Optional)",
"propertyName": "Property to save the resuld (Optional)"
},
"outputFieldLabels": {
"quality": "Phone Number Quality",
"message": "Message"
}
}
},
"functions": [
{
"functionType": "PRE_ACTION_EXECUTION",
"functionSource": "exports.main = function(event, callback) { return callback(transformRequest(event)); }\nfunction transformRequest(request) { return { webhookUrl: '***', body: JSON.stringify({phoneNumber:request.inputFields.Phone_Number, country:request.inputFields.country, propertyName:request.inputFields.propertyName, portalID:request.origin.portalId), contentType: 'application/json', accept: 'application/json', httpMethod: 'POST' }; }"
}
]
}

```

0 Upvotes
1 Reply 1
Jaycee_Lewis
Community Manager
Community Manager

Custom workflow action

Hey, @MTonmoy9 👋 Thanks for your question. Can you tell our community more about where the issue is? Are you getting back specific errors when testing with Postman or when you try using this as a custom-coded workflow action? 

 

I have a few suggestions that may help give our community members more info to troubleshoot with:

  • Adjust the propertyName type from object_coordinates to a relevant type like "string".
  • Ensure the function script properly closes all parentheses and matches your intended logic. (it looks lie you have some missing parentheses)
  • Access the enrolled record’s hs_object_id using event.object.objectId.
  • Debug the workflow using HubSpot’s logs and external testing tools like Postman.
  • Ensure that your actionUrl properly accepts the payload and returns output fields as expected.

Thank you for the additional information. — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes