diff --git a/crc/services/workflow_service.py b/crc/services/workflow_service.py
index fe1534c9..b0fdb219 100755
--- a/crc/services/workflow_service.py
+++ b/crc/services/workflow_service.py
@@ -199,16 +199,17 @@ class WorkflowService(object):
task,
add_docs_and_forms=True) # Assure we try to process the documentation, and raise those errors.
# make sure forms have a form key
- if hasattr(task_api, 'form') and task_api.form is not None and task_api.form.key == '':
- raise ApiError(code='missing_form_key',
+ if hasattr(task_api, 'form') and task_api.form is not None:
+ if task_api.form.key == '':
+ raise ApiError(code='missing_form_key',
message='Forms must include a Form Key.',
task_id=task.id,
task_name=task.get_name())
- WorkflowService.populate_form_with_random_data(task, task_api, required_only)
- if not WorkflowService.validate_form(task, task_api):
- # In the process of completing the form, it is possible for fields to become required
- # based on later fields. Re-run the validation to assure we complete the forms correctly.
WorkflowService.populate_form_with_random_data(task, task_api, required_only)
+ if not WorkflowService.validate_form(task, task_api):
+ # In the process of completing the form, it is possible for fields to become required
+ # based on later fields. Re-run the validation to assure we complete the forms correctly.
+ WorkflowService.populate_form_with_random_data(task, task_api, required_only)
processor.complete_task(task)
if test_until == task.task_spec.name:
@@ -315,11 +316,6 @@ class WorkflowService(object):
# task_id='task.id',
# task_name=task.get_name())
- # If the field is hidden it should not produce a value.
- if field.has_property(Task.FIELD_PROP_HIDE_EXPRESSION):
- if WorkflowService.evaluate_property(Task.FIELD_PROP_HIDE_EXPRESSION, field, task):
- continue
-
# If we have a default_value, try to set the default
if field.default_value:
try:
@@ -334,6 +330,10 @@ class WorkflowService(object):
else:
form_data[field.id] = None
+ # If the field is hidden it should not produce a value.
+ if field.has_property(Task.FIELD_PROP_HIDE_EXPRESSION):
+ if WorkflowService.evaluate_property(Task.FIELD_PROP_HIDE_EXPRESSION, field, task):
+ continue
# If we are only populating required fields, and this isn't required. stop here.
if required_only:
diff --git a/tests/data/required_expressions/required_expressions.bpmn b/tests/data/required_expressions/required_expressions.bpmn
index 73e7b1f6..a4e38ea7 100644
--- a/tests/data/required_expressions/required_expressions.bpmn
+++ b/tests/data/required_expressions/required_expressions.bpmn
@@ -23,6 +23,11 @@
+
+
+
+
+
SequenceFlow_0lvudp8
@@ -39,6 +44,11 @@ if boolean_field:
result = required_if_true
else:
result = required_if_false
+
+# Note that hidden fields with a default
+# value should always exist.
+if not always_set == "always":
+ should_never_get_here
diff --git a/tests/workflow/test_workflow_spec_validation_api.py b/tests/workflow/test_workflow_spec_validation_api.py
index f370b87e..0edf50ec 100644
--- a/tests/workflow/test_workflow_spec_validation_api.py
+++ b/tests/workflow/test_workflow_spec_validation_api.py
@@ -177,7 +177,11 @@ class TestWorkflowSpecValidation(BaseTest):
def test_fields_required_based_on_later_fields_correctly_populates(self):
"""Say you have a form, where the first field is required only if the
SECOND field is checked true. This assures such a case will validate and
- that the variables that should exist (because they are required) do exist."""
+ that the variables that should exist (because they are required) do exist.
+
+ As a bonus test, we also assert that a default field is always present
+ regardless of it's hidden status.
+ """
self.load_test_spec('empty_workflow', master_spec=True)
self.create_reference_document()
errors = self.validate_workflow("required_expressions")