⚙ Operations Hub

SFoltz88
Membro

Custom Code workflow error

Hi all, first post. Not sure I am posting this in the right spot either, so please excuse if I was wrong.

I am fairly new with developing HubSpot and I've just started to get into using custom code actions and so, not 100% sure how they work.
I've made a workflow that is designed to either set due dates or pipeline status of ticket based upon how the ticket was created. there is an if/then branch on the "due date" property being known, so if it was created with a due date known then I can use regular old "set property" based on what the due date is to set the pipeline status.

However, if it is not known, this where things get a little more complex. I want to create actions that say (if pipeline status is "January" then set the "start_date" to {{ currentYear }}-01-01 and "due_date" to {{ currentYear }}-01-31) and so on for every month. I also want there to be a condition for if the month has passed, then change the {{ currentYear }} to {{ nextYear }}.

I've start something and I don't get any syntax erros while writing the code, but it does throw errors when running the code. Here is the code:

 

{
"actions" [
{
"name": "Set date picker property value",
"type": "SET_PROPERTY",
"property": "start",
"value": "{{ year }}-{{ month }}-{{ day }}"
},
{
"name": "Set date for January",
"type": "SET_PROPERTY",
"property": "start",
"value": "{{ currentYear }}-01-01",
"conditions": [
{
"name": "Check if month is January",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51060532"
}
]
},
{
"name": "Set date for February",
"type": "SET_PROPERTY",
"property": "start",
"value": "{{ currentYear }}-02-01",
"conditions": [
{
"name": "Check if month is February",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51060533"
}
]
},
{
"name": "Set date for March",
"type": "SET_PROPERTY",
"property": "start",
"value": "{{ currentYear }}-03-01",
"conditions": [
{
"name": "Check if month is March",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51085609"
}
]
},
{
"name": "Set date for April",
"type": "SET_PROPERTY",
"property": "start",
"value": "{{ currentYear }}-04-01",
"conditions": [
{
"name": "Check if month is April",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51085610"
}
]
},
{
"name": "Set date for May",
"type": "SET_PROPERTY",
"property": "start",
"value": "{{ currentYear }}-05-01",
"conditions": [
{
"name": "Check if month is May",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51085611"
}
]
},
{
"name": "Set date for June",
"type": "SET_PROPERTY",
"property": "start",
"value": "{{ currentYear }}-06-01",
"conditions": [
{
"name": "Check if month is June",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51085612"
}
]
},
{
"name": "Set date for July",
"type": "SET_PROPERTY",
"property": "start",
"value": "{{ currentYear }}-07-01",
"conditions": [
{
"name": "Check if month is July",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51085613"
}
]
},
{
"name": "Set date for August",
"type": "SET_PROPERTY",
"property": "start",
"value": "{{ currentYear }}-08-01",
"conditions": [
{
"name": "Check if month is August",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51619879"
}
]
},
{
"name": "Set date for September",
"type": "SET_PROPERTY",
"property": "start",
"value": "{{ currentYear }}-09-01",
"conditions": [
{
"name": "Check if month is September",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51619880"
}
]
},
{
"name": "Set date for October",
"type": "SET_PROPERTY",
"property": "start",
"value": "{{ currentYear }}-10-01",
"conditions": [
{
"name": "Check if month is October",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "52247554"
}
]
},
{
"name": "Set date for November",
"type": "SET_PROPERTY",
"property": "start",
"value": "{{ currentYear }}-11-01",
"conditions": [
{
"name": "Check if month is November",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "52247555"
}
]
},
{
"name": "Set date for December",
"type": "SET_PROPERTY",
"property": "start",
"value": "{{ currentYear }}-12-01",
"conditions": [
{
"name": "Check if month is December",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "52247556"
}
]
},
{
"name": "Set due date for January",
"type": "SET_PROPERTY",
"property": "due",
"value": "{{ currentYear }}-01-31",
"conditions": [
{
"name": "Check if due month is January",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51060532"
}
]
},
{
"name": "Set due date for February",
"type": "SET_PROPERTY",
"property": "due",
"value": "{{ currentYear }}-02-28",
"conditions": [
{
"name": "Check if due month is February",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51060533"
}
]
},
{
"name": "Set due date for March",
"type": "SET_PROPERTY",
"property": "due",
"value": "{{ currentYear }}-03-31",
"conditions": [
{
"name": "Check if due month is March",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51085609"
}
]
},
{
"name": "Set due date for April",
"type": "SET_PROPERTY",
"property": "due",
"value": "{{ currentYear }}-04-30",
"conditions": [
{
"name": "Check if due month is April",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51085610"
}
]
},
{
"name": "Set due date for May",
"type": "SET_PROPERTY",
"property": "due",
"value": "{{ currentYear }}-05-31",
"conditions": [
{
"name": "Check if due month is May",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51085611"
}
]
},
{
"name": "Set due date for June",
"type": "SET_PROPERTY",
"property": "due",
"value": "{{ currentYear }}-06-30",
"conditions": [
{
"name": "Check if due month is June",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51085612"
}
]
},
{
"name": "Set due date for July",
"type": "SET_PROPERTY",
"property": "due",
"value": "{{ currentYear }}-07-31",
"conditions": [
{
"name": "Check if due month is July",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51085613"
}
]
},
{
"name": "Set due date for August",
"type": "SET_PROPERTY",
"property": "due",
"value": "{{ currentYear }}-08-30",
"conditions": [
{
"name": "Check if due month is August",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51619879"
}
]
},
{
"name": "Set due date for September",
"type": "SET_PROPERTY",
"property": "due",
"value": "{{ currentYear }}-09-30",
"conditions": [
{
"name": "Check if due month is September",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "51619880"
}
]
},
{
"name": "Set due date for October",
"type": "SET_PROPERTY",
"property": "due",
"value": "{{ currentYear }}-10-31",
"conditions": [
{
"name": "Check if due month is October",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "52247554"
}
]
},
{
"name": "Set due date for November",
"type": "SET_PROPERTY",
"property": "due",
"value": "{{ currentYear }}-11-30",
"conditions": [
{
"name": "Check if due month is November",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "52247555"
}
]
},
{
"name": "Set due date for December",
"type": "SET_PROPERTY",
"property": "due",
"value": "{{ currentYear }}-12-31",
"conditions": [
{
"name": "Check if due month is December",
"type": "VALUE_EQUALS",
"leftValue": "{{ ticket.properties.hs_pipeline_stage }}",
"rightValue": "52247556"
}
]
}
// Add more actions for each month here
]
}

 


Here is the error that it throws:

2023-03-08T16:54:28.275Z	ERROR	Invoke Error 	{"errorType":"TypeError","errorMessage":"customerPayload.main is not a function","stack":["TypeError: customerPayload.main is not a function","    at Runtime.exports.hubspot_handler [as handler] (/var/task/hubspotHandler.js:6:21)","    at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1085:29)"]}

 

Am I way off base here? Any help?

0 Avaliação positiva
1 Resposta 1
kvlschaefer
Gerente da Comunidade
Gerente da Comunidade

Custom Code workflow error

Hi @SFoltz88,

 

Thanks for reaching out!

 

I would like to invite our subject matter experts to see if they have insight.

Hi @Teun@LMeert@ChrisoKlepke - Any ideas why this doesn't work? Thank you!

 

Best,

Kristen


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !
0 Avaliação positiva