From a81f25f0eea8794bd07fe8cb25f2664d9454a299 Mon Sep 17 00:00:00 2001 From: alicia pritchett Date: Thu, 16 Dec 2021 14:47:04 -0500 Subject: [PATCH] Just kidding. We should make deepcopy and put in fake data 4 valdiation see above. previously i deleted this, because i didnt want unitializsed data in task data. well heres a hint. don't put it in task data. make a deep copy and hold on to that for validation pursposes --- crc/services/workflow_service.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crc/services/workflow_service.py b/crc/services/workflow_service.py index 2ed78446..1351241a 100755 --- a/crc/services/workflow_service.py +++ b/crc/services/workflow_service.py @@ -376,10 +376,15 @@ class WorkflowService(object): def evaluate_property(property_name, field, task): expression = field.get_property(property_name) - data = task.data + data = copy.deepcopy(task.data) + # If there's a field key with no initial value, give it one (None) + for field in task.task_spec.form.fields: + if field.id not in data: + data[field.id] = None + if field.has_property(Task.FIELD_PROP_REPEAT): # Then you must evaluate the expression based on the data within the group, if that data exists. - # There may not be data available in the group, if no groups where added + # There may not be data available in the group, if no groups were added group = field.get_property(Task.FIELD_PROP_REPEAT) if group in task.data and len(task.data[group]) > 0: # Here we must make the current group data top level (as it would be in a repeat section) but @@ -391,6 +396,9 @@ class WorkflowService(object): else: return None # We may not have enough information to process this + if not field.has_property(Task.FIELD_PROP_REPEAT): + new_data = copy.deepcopy(task.data) + try: return task.workflow.script_engine._evaluate(expression, **data) except Exception as e: