<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Custom Code workflow error in Data Hub</title>
    <link>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-error/m-p/766024#M1360</link>
    <description>&lt;P&gt;Hi all, first post. Not sure I am posting this in the right spot either, so please excuse if I was wrong.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;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&amp;nbsp;&lt;EM&gt;with&lt;/EM&gt; a due date known then I can use regular old "set property" based on what the due date is to set the pipeline status.&lt;BR /&gt;&lt;BR /&gt;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 }}.&lt;BR /&gt;&lt;BR /&gt;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:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
"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
]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Here is the error that it throws:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;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)"]}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I way off base here? Any help?&lt;/P&gt;</description>
    <pubDate>Wed, 08 Mar 2023 18:10:06 GMT</pubDate>
    <dc:creator>SFoltz88</dc:creator>
    <dc:date>2023-03-08T18:10:06Z</dc:date>
    <item>
      <title>Custom Code workflow error</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-error/m-p/766024#M1360</link>
      <description>&lt;P&gt;Hi all, first post. Not sure I am posting this in the right spot either, so please excuse if I was wrong.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;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&amp;nbsp;&lt;EM&gt;with&lt;/EM&gt; a due date known then I can use regular old "set property" based on what the due date is to set the pipeline status.&lt;BR /&gt;&lt;BR /&gt;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 }}.&lt;BR /&gt;&lt;BR /&gt;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:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
"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
]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Here is the error that it throws:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;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)"]}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I way off base here? Any help?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 18:10:06 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-error/m-p/766024#M1360</guid>
      <dc:creator>SFoltz88</dc:creator>
      <dc:date>2023-03-08T18:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Code workflow error</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-error/m-p/767829#M1361</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/519711"&gt;@SFoltz88&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for reaching out!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to invite our subject matter experts to see if they have insight.&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/101258"&gt;@Teun&lt;/a&gt;,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/257487"&gt;@LMeert&lt;/a&gt;,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/241684"&gt;@ChrisoKlepke&lt;/a&gt;&amp;nbsp;- Any ideas why this doesn't work? Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Kristen&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 12:53:40 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Custom-Code-workflow-error/m-p/767829#M1361</guid>
      <dc:creator>kvlschaefer</dc:creator>
      <dc:date>2023-03-13T12:53:40Z</dc:date>
    </item>
  </channel>
</rss>

