Custom code output is not defined

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

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
 }
 }

@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:

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

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