# Custom code output is not defined

**URL:** <https://community.hubspot.com/t/custom-code-output-is-not-defined/107074>\
**Category:** APIs & Integrations\
**Tags:** python, workflows\
**Created:** [May 14, 2024, 7:53am UTC](https://community.hubspot.com/t/custom-code-output-is-not-defined/107074 "2024-05-14T07:53:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhordos](https://avatars.discourse-cdn.com/v4/letter/d/b782af/32.png) [@dhordos](https://community.hubspot.com/u/dhordos)\
**Post date:** [May 14, 2024, 7:53am UTC](https://community.hubspot.com/t/custom-code-output-is-not-defined/107074/1 "2024-05-14T07:53:08Z")

</div>

hi there,  
I have created a custom code, see below. In the data output section I have added test\_sao\_enter\_2 as a date type variable. The code executes successfully, however the data output says the following: “Make sure to define the output “test\_sao\_enter\_2” in the data outputs form using the same name you used in the code.”.  
I have no idea what the problem could be. Could you please help me?  
Thanks in advance,  
Donát

```lia-code-sample
from datetime import datetime

def main(event):

 enter_dr = event.get('inputFields', {}).get('hs_v2_date_entered_85505052', None)
 enter_pc = event.get('inputFields', {}).get('hs_v2_date_entered_85505053', None)
 enter_n = event.get('inputFields', {}).get('hs_v2_date_entered_85504059', None)
 enter_c = event.get('inputFields', {}).get('hs_v2_date_entered_85504060', None)
 enter_cl = event.get('inputFields', {}).get('hs_v2_date_entered_85505055', None)

 def parse_datetime(date_str):
 if date_str:
 try:
 return datetime.strptime(date_str, '%Y-%m-%dT%H:%M:%S.%fZ')
 except ValueError:
 return None 
 return None

 dates = [parse_datetime(d) for d in [enter_dr, enter_pc, enter_n, enter_c] if d]
 enter_cl_date = parse_datetime(enter_cl)

 valid_dates = [date for date in dates if date and (not enter_cl_date or date > enter_cl_date)]

 if valid_dates:
 test_sao_enter_2 = min(valid_dates).isoformat() 
 else:
 test_sao_enter_2 = None 

 return {
 "outputFields": {
 "test_sao_enter_2": test_sao_enter_2
 }
 }

```

---

<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:** [May 14, 2024, 3:11pm UTC](https://community.hubspot.com/t/custom-code-output-is-not-defined/107074/2 "2024-05-14T15:11:05Z")

</div>

@dhordos - the error message is simply informing you that the output properties also need to be defined in the custom code setup dialog. The only pre-defined output property that can be passed to subsequent workflow steps is the execution status.

See the ‘add output’ link in the screenshot example below:

 ![SteveHTM_0-1715699297186.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/7/0/708d254148cd7f3e10dad492f7dfeab26aa87c95.png)

You may say ‘why do I have to define these properties twice?’ - I’m not defending this custom code dialog - although it has improved greatly ove the time I have been using it.

Good luck!

Steve

---

<div class="post-metadata">

**Author:** ![dhordos](https://avatars.discourse-cdn.com/v4/letter/d/b782af/32.png) [@dhordos](https://community.hubspot.com/u/dhordos)\
**Post date:** [May 14, 2024, 3:25pm UTC](https://community.hubspot.com/t/custom-code-output-is-not-defined/107074/3 "2024-05-14T15:25:53Z")

</div>

**Hi Steve,**

**thank you for your reply. As I mentioned I have defined this variable in the output section and still not accepting it.**

**best,**

**Donát**
