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
This commit is contained in:
alicia pritchett 2021-12-16 14:47:04 -05:00
parent 421e4fd9aa
commit a81f25f0ee
1 changed files with 10 additions and 2 deletions

View File

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