<?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 Workflow custom code setting date issue in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Workflow-custom-code-setting-date-issue/m-p/1109281#M80358</link>
    <description>&lt;DIV class=""&gt;I have a workflow where I take an HS date field (deal created date) and set it to a new date variable using custom code. Only passing the date variable through the custom code results in setting 'Invalid date'.The actual use case is more complex than just passing data through custom code: getting the minimum of multiple dates with specific fallbacks and rules. So, I need the custom code but I can't get the simple version to work. Attempts so far:&lt;/DIV&gt;&lt;UL class=""&gt;&lt;LI&gt;Set to deal create date: success&lt;/LI&gt;&lt;LI&gt;Set to custom code output: Invalid date&lt;/LI&gt;&lt;LI&gt;Set to format of custom code output: Invalid date&lt;/LI&gt;&lt;/UL&gt;&lt;DIV class=""&gt;Please advise&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Custom code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;P&gt;def main(event):&lt;BR /&gt;try:&lt;BR /&gt;# Retrieve all relevant fields (do not alter the dates)&lt;BR /&gt;created_date = event["inputFields"].get("createdate", None)&lt;BR /&gt;&lt;BR /&gt;# Return output fields without altering the date values&lt;BR /&gt;return {&lt;BR /&gt;"outputFields": {&lt;BR /&gt;"created_date": created_date&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;except Exception as error:&lt;BR /&gt;# Handle unexpected errors&lt;BR /&gt;return {&lt;BR /&gt;"outputFields": {&lt;BR /&gt;"created_date": None,&lt;BR /&gt;"error": str(error),&lt;BR /&gt;}&lt;BR /&gt;}&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-02-14 at 16.21.40.png" style="width: 792px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/138519i34F79A42B61A4C09/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-02-14 at 16.21.40.png" alt="Screenshot 2025-02-14 at 16.21.40.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-02-14 at 16.22.18.png" style="width: 325px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/138520iD20F09A114B57EE5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-02-14 at 16.22.18.png" alt="Screenshot 2025-02-14 at 16.22.18.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-02-14 at 16.22.30.png" style="width: 779px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/138521i69470E784248F0CD/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-02-14 at 16.22.30.png" alt="Screenshot 2025-02-14 at 16.22.30.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-02-14 at 16.22.47.png" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/138522i15B10AC703F7703D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-02-14 at 16.22.47.png" alt="Screenshot 2025-02-14 at 16.22.47.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-02-14 at 16.23.30.png" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/138523i8820E1A75266C6FB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-02-14 at 16.23.30.png" alt="Screenshot 2025-02-14 at 16.23.30.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 14 Feb 2025 15:29:00 GMT</pubDate>
    <dc:creator>RHussein</dc:creator>
    <dc:date>2025-02-14T15:29:00Z</dc:date>
    <item>
      <title>Workflow custom code setting date issue</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Workflow-custom-code-setting-date-issue/m-p/1109281#M80358</link>
      <description>&lt;DIV class=""&gt;I have a workflow where I take an HS date field (deal created date) and set it to a new date variable using custom code. Only passing the date variable through the custom code results in setting 'Invalid date'.The actual use case is more complex than just passing data through custom code: getting the minimum of multiple dates with specific fallbacks and rules. So, I need the custom code but I can't get the simple version to work. Attempts so far:&lt;/DIV&gt;&lt;UL class=""&gt;&lt;LI&gt;Set to deal create date: success&lt;/LI&gt;&lt;LI&gt;Set to custom code output: Invalid date&lt;/LI&gt;&lt;LI&gt;Set to format of custom code output: Invalid date&lt;/LI&gt;&lt;/UL&gt;&lt;DIV class=""&gt;Please advise&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Custom code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;P&gt;def main(event):&lt;BR /&gt;try:&lt;BR /&gt;# Retrieve all relevant fields (do not alter the dates)&lt;BR /&gt;created_date = event["inputFields"].get("createdate", None)&lt;BR /&gt;&lt;BR /&gt;# Return output fields without altering the date values&lt;BR /&gt;return {&lt;BR /&gt;"outputFields": {&lt;BR /&gt;"created_date": created_date&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;except Exception as error:&lt;BR /&gt;# Handle unexpected errors&lt;BR /&gt;return {&lt;BR /&gt;"outputFields": {&lt;BR /&gt;"created_date": None,&lt;BR /&gt;"error": str(error),&lt;BR /&gt;}&lt;BR /&gt;}&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-02-14 at 16.21.40.png" style="width: 792px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/138519i34F79A42B61A4C09/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-02-14 at 16.21.40.png" alt="Screenshot 2025-02-14 at 16.21.40.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-02-14 at 16.22.18.png" style="width: 325px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/138520iD20F09A114B57EE5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-02-14 at 16.22.18.png" alt="Screenshot 2025-02-14 at 16.22.18.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-02-14 at 16.22.30.png" style="width: 779px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/138521i69470E784248F0CD/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-02-14 at 16.22.30.png" alt="Screenshot 2025-02-14 at 16.22.30.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-02-14 at 16.22.47.png" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/138522i15B10AC703F7703D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-02-14 at 16.22.47.png" alt="Screenshot 2025-02-14 at 16.22.47.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-02-14 at 16.23.30.png" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/138523i8820E1A75266C6FB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-02-14 at 16.23.30.png" alt="Screenshot 2025-02-14 at 16.23.30.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 14 Feb 2025 15:29:00 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Workflow-custom-code-setting-date-issue/m-p/1109281#M80358</guid>
      <dc:creator>RHussein</dc:creator>
      <dc:date>2025-02-14T15:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Workflow custom code setting date issue</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Workflow-custom-code-setting-date-issue/m-p/1109446#M80368</link>
      <description>&lt;P&gt;For formatting dates: YYYY-MM-DDT00:00:00.000Z&lt;BR /&gt;This is ISO 8601 formatting, if the property is only a DATE property, the time needs to be set to midnight in UTC, Same with DATETIME, except you set the time not at midnight, your actual time.&lt;/P&gt;
&lt;P&gt;Now this is how you input it via the api.&lt;/P&gt;
&lt;P&gt;Since you are already in a custom code block, just add your api call to update that record property!&lt;/P&gt;
&lt;P&gt;I've never had a lot of success setting a date or datetime inside a workflow. I just break out the api update.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2025 21:31:23 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Workflow-custom-code-setting-date-issue/m-p/1109446#M80368</guid>
      <dc:creator>nickdeckerdevs1</dc:creator>
      <dc:date>2025-02-14T21:31:23Z</dc:date>
    </item>
  </channel>
</rss>

