In spiff_task_to_api_task, when looping through fields, if the field doesn't have a value, we now try to set it with the default value

In test_spec, we now check for FIELD_PROP_VALUE_EXPRESSION when setting default values
This commit is contained in:
mike cullerton 2021-01-22 10:00:28 -05:00
parent 5b13195182
commit 00d9276483
1 changed files with 7 additions and 1 deletions

View File

@ -153,8 +153,11 @@ class WorkflowService(object):
if WorkflowService.evaluate_property(Task.FIELD_PROP_HIDE_EXPRESSION, field, task):
continue
# If we set the default with value_expression
if field.has_property(Task.FIELD_PROP_VALUE_EXPRESSION):
form_data[field.id] = WorkflowService.get_default_value(field, task)
# If there is a default value, set it.
if hasattr(field,'default_value') and field.default_value:
elif hasattr(field, 'default_value') and field.default_value:
form_data[field.id] = WorkflowService.get_default_value(field, task)
# If we are only populating required fields, and this isn't required. stop here.
@ -488,6 +491,9 @@ class WorkflowService(object):
task.form = spiff_task.task_spec.form
for i, field in enumerate(task.form.fields):
task.form.fields[i] = WorkflowService.process_options(spiff_task, field)
# If there is a default value, set it.
if field.id not in task.data and WorkflowService.get_default_value(field, spiff_task) is not None:
task.data[field.id] = WorkflowService.get_default_value(field, spiff_task)
task.documentation = WorkflowService._process_documentation(spiff_task)
# All ready tasks should have a valid name, and this can be computed for