How to perform multiple validations + display all validation error messages at once
Hi,
how can one in Bizagi set to perform multiple validations + display error messages at once?
For now, the only option seems to be to use of CHelper.ThrowValidationError, however, at first validation error the first error message will be displayed and further code execution will be stopped (as Throw is supposed to do).
So in expression (e.g. On Exit activity action of some process)
- CHelper.ThrowValidationError("Error 1");
CHelper.ThrowValidationError("Error 2");
will display error "Error 1" but not also "Error 2".
This means that for 10 wrongfully inserted data on the form we get 1 error, we fix that one, we get 2nd error, we fix that one, we get 3rd error, we fix that one...
I would like to get all 10 validation errors at once (they are independent of each other), not one by one.
Can this be achieved in Bizagi?
Good afternoon Dejan,
I can think of a way to do it and it is by concatenating all messages that you need to show and depending on each of the conditions that you need to evaluate in a single ThrowValidationErrorMessage more or less as follows:
var Message = "";
if (BAIsTrue (Condition1)) {
Message + = "Condition 1 was not met" + "\ r \ n";
}
.
.
.
if (BAIsTrue (ConditionN)) {
Message + = "Condition N was not met" + "\ r \ n";
}
if (Message.Length> 2) {
CHelper.ThrowValidationErrorMessage (Message);
}
Try it Dejan, it will surely work for you.
Greetings
That is quite a decent solution, building a message string.
Thanks.
Comments have been locked on this page!