Hi Team,
We are facing an issue with the Workflow API. Specifically, the POST_FETCH_OPTIONS is not passing the selected campus input field value, and the options URL in the cascade dropdown list is not being updated.
We are using the following code to retrieve the first dropdown’s selected value and pass it to the second dropdown’s options URL. However, it’s no longer working as expected:
const campusid = responseData.data.fields.campusInput.fieldValue.value;
Here is the structure of the API configuration:
{
“actionUrl”: “https://test.com/integration/hubspot/webhook”,
“published”: true,
“objectTypes”: [“CONTACT”, “Companies”, “Deals”, “Tickets”, “Quotes”, “Products”, “Invoices”, “Communications”],
“inputFields”: [
{
“typeDefinition”: {
“name”: “messageInput”,
“type”: “string”,
“fieldType”: “text”
},
“supportedValueTypes”: [“STATIC_VALUE”],
“isRequired”: true
},
{
“typeDefinition”: {
“name”: “campusInput”,
“type”: “enumeration”,
“fieldType”: “select”,
“optionsUrl”: “https://test.com/integration/hubspot/orgunit/campus-selection”
},
“supportedValueTypes”: [“STATIC_VALUE”]
},
{
“typeDefinition”: {
“name”: “groupInput”,
“type”: “enumeration”,
“fieldType”: “select”,
“optionsUrl”: “https://test.com/integration/hubspot/orgunit/campus-selection”
},
“supportedValueTypes”: [“STATIC_VALUE”]
}
],
“objectRequestOptions”: {
“properties”: [“mobilephone”, “email”]
},
“labels”: {
“en”: {
“inputFieldLabels”: {
“messageInput”: “Message”,
“groupInput”: “Group”,
“campusInput”: “Campus”
},
“actionName”: “Send Message V1_08052024”,
“actionDescription”: “Send Message V1_08052024”,
“appDisplayName”: “Powered By Text”,
“actionCardContent”: “Send through Powered By Text”
}
},
“functions”: [
{
“functionType”: “POST_ACTION_EXECUTION”,
“functionSource”: “exports.main = (event, callback) => { callback({ outputFields: { myOutput: \“example output value\” } }); }”
},
{
“functionType”: “POST_FETCH_OPTIONS”,
“id”: “campusInput”,
“functionSource”: “const axios = require(‘axios’); exports.main = async (event, callback) => { try { const responseData = JSON.parse(event.responseBody); const portalId = responseData.data.origin.portalId; const campusurl='https://test.com/integration/hubspot/orgunit/'+portalId; const response = await axios.get(campusurl); const data = response.data.data; const options = data.map(item => ({\“label\”: item.name, \“value\”: item.id})); callback({ \“options\”: options }); } catch (error) { console.error(‘Error fetching options:’, error); callback({ \“options\”: [] }); } }”
},
{
“functionType”: “POST_FETCH_OPTIONS”,
“id”: “groupInput”,
“functionSource”: “const axios = require(‘axios’); exports.main = async (event, callback) => { try { const responseData = JSON.parse(event.responseBody); const portalId = responseData.data.origin.portalId; const campusid=responseData.data.fields.campusInput.fieldValue.value; const groupurl='https://test.com/integration/hubspot/orgunit/'+ campusid + ‘/group/’+ portalId; await axios.post(‘https://webhook.site/7e966653-3fe1-4bed-8542-706abfb86bb0’, { groupUrl: groupurl }); const response = await axios.get(groupurl); const data = response.data.data; const options = data.map(item => ({\“label\”: item.name, \“value\”: item.id})); callback({ \“options\”: options }); } catch (error) { console.error(‘Error fetching options:’, error); callback({ \“options\”: [] }); } }”
}
]
}
Could you please help investigate and advise on potential solutions to resolve this issue?
Thank you.
Best regards,
Suresh