# custom coded Workflow not updating outputs correctly

**URL:** <https://community.hubspot.com/t/custom-coded-workflow-not-updating-outputs-correctly/124657>\
**Category:** Data Hub\
**Tags:** workflow-extension\
**Created:** [January 23, 2025, 5:46pm UTC](https://community.hubspot.com/t/custom-coded-workflow-not-updating-outputs-correctly/124657 "2025-01-23T17:46:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![IDevole](https://avatars.discourse-cdn.com/v4/letter/i/6de8d8/32.png) [@IDevole](https://community.hubspot.com/u/IDevole)\
**Post date:** [January 23, 2025, 5:46pm UTC](https://community.hubspot.com/t/custom-coded-workflow-not-updating-outputs-correctly/124657/1 "2025-01-23T17:46:37Z")

</div>

Hello,

I created a workflow that checks:

- if a contact ever had a meeting booked? (regardless of the outcome)
- The date of the first meeting that was actually held with the contact (outcome = Completed)
- 

 ![1.PNG](https://d2qpr2jzcazej7.cloudfront.net/original/3X/a/2/a20c857a464c2a8d4287a7e61c592952abf17171.png)

 ![2.PNG](https://d2qpr2jzcazej7.cloudfront.net/original/3X/7/1/7130e0c6d9b848b4f1c0e63a4b7300d30d4495f0.png)

 ![3.PNG](https://d2qpr2jzcazej7.cloudfront.net/original/3X/1/c/1cdf492ce38f99a91633937a4b1ea36b2f0a0b74.png)

 ![4.PNG](https://d2qpr2jzcazej7.cloudfront.net/original/1X/f3bddfaeac2de68f0266b54db063f18a5ee3f9cc.png)

 ![5.PNG](https://d2qpr2jzcazej7.cloudfront.net/original/2X/6/6675566042e1faacc3c1809e442210f01c796f10.png)

 ![6.PNG](https://d2qpr2jzcazej7.cloudfront.net/original/2X/0/0ab1750bc8f154f903af8cb90b08bc027fbcdcea.png)

 ![7.PNG](https://d2qpr2jzcazej7.cloudfront.net/original/3X/5/7/571be7da124733d0d33e657a10e806cd4895c83c.png)

 ![8.PNG](https://d2qpr2jzcazej7.cloudfront.net/original/3X/8/9/8908ad55e2cc2f975f3e8ce8bd74bafc0889268e.png)

It has this custom code action:

```lia-code-sample
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,
 }
 }

```

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.  
What can I be doing wrong?

---

<div class="post-metadata">

**Author:** ![kennedyp](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@kennedyp](https://community.hubspot.com/u/kennedyp)\
**Post date:** [January 23, 2025, 10:24pm UTC](https://community.hubspot.com/t/custom-coded-workflow-not-updating-outputs-correctly/124657/2 "2025-01-23T22:24:34Z")

</div>

Hi [@IDevolé](https://community.hubspot.com/t5/user/viewprofilepage/user-id/888233)! Welcome to the Community-- happy to have you here 😊

I want to invite some subject matter experts to see if they have any tips or insight.

Hey @LMeert, @Anton, @DanielSanchez do you have any troubleshooting suggestions?

---

<div class="post-metadata">

**Author:** ![kennedyp](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@kennedyp](https://community.hubspot.com/u/kennedyp)\
**Post date:** [February 6, 2025, 10:40pm UTC](https://community.hubspot.com/t/custom-coded-workflow-not-updating-outputs-correctly/124657/3 "2025-02-06T22:40:31Z")

</div>

Are you still having trouble with this custom code action, [@IDevolé](https://community.hubspot.com/t5/user/viewprofilepage/user-id/888233)?  
I tested this code in my own workflow using the tester and I see the same warning on the output: _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._  
I want to offer a couple of similar threads that may point you to some follow up steps:

- [Custom code output is not defined](https://community.hubspot.com/t5/APIs-Integrations/Custom-code-output-is-not-defined/td-p/975905) (helped by @SteveHTM)
- [Custom Workflow action not showing outputs](https://community.hubspot.com/t5/9881-Operations-Hub/Custom-Workflow-action-not-showing-outputs/m-p/597025) (helped by @sam1989 & @LMeert)

_Best,_

Kennedy

---

<div class="post-metadata">

**Author:** ![SteveHTM](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/stevehtm/32/22074_2.png) [@SteveHTM](https://community.hubspot.com/u/SteveHTM)\
**Post date:** [February 6, 2025, 11:47pm UTC](https://community.hubspot.com/t/custom-coded-workflow-not-updating-outputs-correctly/124657/4 "2025-02-06T23:47:27Z")

</div>

[@IDevolé](https://community.hubspot.com/t5/user/viewprofilepage/user-id/888233) - 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.

Steve
