Groovy issue
I have, what should be a simple validation requirement that I cant figure out how to implement in Groovy. It needs to check:
If Field X is empty, fail validation - give error message
If Field X is completed and field Y is empty, fail validation - give different error message
If Field X is completed and field Y is completed, PASS validation.
Sounds simple, but I cant get it to work. Any help would be greatly appreciated as this concept needs to be applied to many situations
THANKS
S Benson
Posted 1 year ago · Edited 1 year ago·Last reply 1 year ago
4 comments
stevenwood
·1 year ago · EditedThere are a couple of things that might help make this possible. There are multiline Validation rules using anyOf and allOf that might work.
https://productresources.collibra.com/docs/collibra/latest/Content/Settings/OperatingModel/ValidationRules/ValidationLogic/ref_multi-line-boolean-expressions.htm
This is also might need to use Given, When, and Then to make the logic work.
https://productresources.collibra.com/docs/collibra/latest/Content/Settings/OperatingModel/ValidationRules/ValidationLogic/ref_validation-script-examples.htm
It would be best if you also considered having a WF to drive the input of the content rather than fixing the issues after the fact. With the new WF designer, you can build forms that do most of the validation in the form and reduce problems that could appear later.
Steven
Bruno Barić
·1 year ago · EditedThis may help. I don't understand what do you mean by completed.
import com.collibra.dgc.workflow.api.exception.WorkflowException;
if (X == null) {
def dgcError = new WorkflowException("X is empty");
dgcError.setTitleMessage("Workflow not started");
throw dgcError;
};
Bruno Barić
·1 year ago · EditedThis may help. I don't understand what do you mean by completed.
import com.collibra.dgc.workflow.api.exception.WorkflowException;
if (X == null) {
def dgcError = new WorkflowException("X is empty");
dgcError.setTitleMessage("Workflow not started");
throw dgcError;
};
S Benson
OP1 year ago · Edited@bbaric ,
Thanks for the ideas, but this is a validation routine, not a WF.
Sorry I wasnt clear about "Completed", what I meant was the field had been completed or filled in. For example, consider the question pair:
Question 1: Are you over 18 years old? If the answer is yes, the person is required to respond to Question 2 (Whatever that might be).
If the response to Question 1 is no, then question 2 does not need a response.
I am trying to write a validation that ensures, if question 1 is answered yes, then question 2 is also answered.
I hope that helps,
Scott