<?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 Re: custom coded Workflow not updating outputs correctly in Data Hub</title>
    <link>https://community.hubspot.com/t5/Data-Hub/custom-coded-Workflow-not-updating-outputs-correctly/m-p/1105245#M2834</link>
    <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/888233"&gt;@IDevolé&lt;/a&gt;&amp;nbsp;- all I can see is a rather trivial issue of an extra comma at the end of the outputFields JSON definition. I can't exactly reproduce what's happening here, but its clearly essential to get the output block return value definitions exactly matching the outputField{} setup.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Steve&lt;/P&gt;</description>
    <pubDate>Thu, 06 Feb 2025 23:47:27 GMT</pubDate>
    <dc:creator>SteveHTM</dc:creator>
    <dc:date>2025-02-06T23:47:27Z</dc:date>
    <item>
      <title>custom coded Workflow not updating outputs correctly</title>
      <link>https://community.hubspot.com/t5/Data-Hub/custom-coded-Workflow-not-updating-outputs-correctly/m-p/1098707#M2814</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I created a workflow that checks:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;if a&amp;nbsp;contact ever had a meeting booked? (regardless of the outcome)&lt;/LI&gt;
&lt;LI&gt;The date of the first meeting that was actually held with the contact (outcome = Completed)&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.PNG" style="width: 785px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/136748i8FDA8EAF8BD4118A/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.PNG" alt="1.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.PNG" style="width: 462px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/136749i4BD7342D30EE9D05/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.PNG" alt="2.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3.PNG" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/136746i85AC66D7D2C56D34/image-size/large?v=v2&amp;amp;px=999" role="button" title="3.PNG" alt="3.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="4.PNG" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/136747iE93DD149A1094307/image-size/large?v=v2&amp;amp;px=999" role="button" title="4.PNG" alt="4.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="5.PNG" style="width: 485px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/136750iFBDF38D6A34E7D2B/image-size/large?v=v2&amp;amp;px=999" role="button" title="5.PNG" alt="5.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="6.PNG" style="width: 494px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/136751iAE79A9491E05C411/image-size/large?v=v2&amp;amp;px=999" role="button" title="6.PNG" alt="6.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="7.PNG" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/136752i376D1397C5EA0CA3/image-size/large?v=v2&amp;amp;px=999" role="button" title="7.PNG" alt="7.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="8.PNG" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/136753i59B9E69B3DC625E0/image-size/large?v=v2&amp;amp;px=999" role="button" title="8.PNG" alt="8.PNG" /&gt;&lt;/span&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;It has this custom code action:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;from datetime import datetime
import logging

def main(event):
    # Initialize placeholders
    has_meetings_booked = False
    first_meeting_date = None

    # Extract input data
    meetings_data = event["inputFields"].get("meeting_details", [])

    # Log the raw data for debugging
    logging.debug(f"Raw Meeting Details: {meetings_data}")

    # Check if there are any meetings
    if isinstance(meetings_data, list) and meetings_data:
        has_meetings_booked = True

        # Filter for completed meetings with valid start_date
        completed_meetings = [
            m for m in meetings_data
            if m.get("outcome") == "Completed" and m.get("start_date")
        ]

        # Log completed meetings
        logging.debug(f"Completed Meetings: {completed_meetings}")

        # If there are completed meetings, find the earliest start_date
        if completed_meetings:
            try:
                earliest_date = min(
                    datetime.fromisoformat(m.get("start_date"))
                    for m in completed_meetings
                )
                # Set the time to midnight (UTC)
                earliest_date_midnight = earliest_date.replace(hour=0, minute=0, second=0, microsecond=0)
                first_meeting_date = earliest_date_midnight.isoformat() + "Z"
            except ValueError as e:
                logging.error(f"Date Parsing Error: {e}")
                first_meeting_date = None

    # Return the outputs
    return {
        "outputFields": {
            "has_meetings_booked": has_meetings_booked,
            "first_meeting_date": first_meeting_date,
        }
    }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I test it, is says that "has_meetings_booked = False" and "first_meeting_date" is invalid, even though the contact has two meetings, one scheduled and the other completed.&lt;BR /&gt;&lt;BR /&gt;What can I be doing wrong?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 19:44:59 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/custom-coded-Workflow-not-updating-outputs-correctly/m-p/1098707#M2814</guid>
      <dc:creator>IDevolé</dc:creator>
      <dc:date>2025-01-24T19:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: Workflow not updating outputs correctly</title>
      <link>https://community.hubspot.com/t5/Data-Hub/custom-coded-Workflow-not-updating-outputs-correctly/m-p/1098885#M2815</link>
      <description>&lt;P&gt;Hi &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/888233"&gt;@IDevolé&lt;/a&gt;&lt;/SPAN&gt;! Welcome to the Community-- happy to have you here &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to invite some subject matter experts to see if they have any tips or insight.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hey &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/257487"&gt;@LMeert&lt;/a&gt;&lt;/SPAN&gt;, &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/17186"&gt;@Anton&lt;/a&gt;, &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/76319"&gt;@DanielSanchez&lt;/a&gt;&lt;/SPAN&gt; do you have any troubleshooting suggestions?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2025 22:24:34 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/custom-coded-Workflow-not-updating-outputs-correctly/m-p/1098885#M2815</guid>
      <dc:creator>kennedyp</dc:creator>
      <dc:date>2025-01-23T22:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: custom coded Workflow not updating outputs correctly</title>
      <link>https://community.hubspot.com/t5/Data-Hub/custom-coded-Workflow-not-updating-outputs-correctly/m-p/1105222#M2833</link>
      <description>&lt;P&gt;Are you still having trouble with this custom code action, &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/888233"&gt;@IDevolé&lt;/a&gt;&lt;/SPAN&gt;?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I tested this code in my own workflow using the tester and I see the same warning on the output: &lt;I&gt;Make sure to define the output "has_meetings_booked" in the outputFields block in the code using the same name you used in the data outputs form.&lt;/I&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I want to offer a couple of similar threads that may point you to some follow up steps:&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
 &lt;LI&gt;&lt;A href="https://community.hubspot.com/t5/APIs-Integrations/Custom-code-output-is-not-defined/td-p/975905" target="_blank"&gt;Custom code output is not defined&lt;/A&gt; (helped by &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/63499"&gt;@SteveHTM&lt;/a&gt;&lt;/SPAN&gt;)&lt;/LI&gt;
 &lt;LI&gt;&lt;A href="https://community.hubspot.com/t5/9881-Operations-Hub/Custom-Workflow-action-not-showing-outputs/m-p/597025" target="_blank"&gt;Custom Workflow action not showing outputs&lt;/A&gt; (helped by &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/608043"&gt;@sam1989&lt;/a&gt;&lt;/SPAN&gt; &amp;amp; &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/257487"&gt;@LMeert&lt;/a&gt;&lt;/SPAN&gt;)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;Best,&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;Kennedy&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2025 22:40:31 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/custom-coded-Workflow-not-updating-outputs-correctly/m-p/1105222#M2833</guid>
      <dc:creator>kennedyp</dc:creator>
      <dc:date>2025-02-06T22:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: custom coded Workflow not updating outputs correctly</title>
      <link>https://community.hubspot.com/t5/Data-Hub/custom-coded-Workflow-not-updating-outputs-correctly/m-p/1105245#M2834</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/888233"&gt;@IDevolé&lt;/a&gt;&amp;nbsp;- all I can see is a rather trivial issue of an extra comma at the end of the outputFields JSON definition. I can't exactly reproduce what's happening here, but its clearly essential to get the output block return value definitions exactly matching the outputField{} setup.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Steve&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2025 23:47:27 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/custom-coded-Workflow-not-updating-outputs-correctly/m-p/1105245#M2834</guid>
      <dc:creator>SteveHTM</dc:creator>
      <dc:date>2025-02-06T23:47:27Z</dc:date>
    </item>
  </channel>
</rss>

