Validation -required


#1

Hello Everyone

Greeting!!!

i have two attributes in the one user task the First one like (enum) approve or Rejected. the second attributes is Reason like string.

How can i convert Reason like validation -required when i selected Rejected from Camunda BPM modeler

Regards
Suhaib Sultan


#2

Hi Suhaib,
as far as I know I think you can not do the “conditional validation” with the generated task forms.
I suggest that you should create your own task form (embedded task form), where you can easily do this.
See this https://docs.camunda.org/manual/7.6/user-guide/task-forms/#embedded-task-forms for more information about the forms.
Hope that helps.
Cheers,
Lukas


#3

i think i need to mention that in java code but i do not know how can i mention if i selected Rejected it should be required.

this Java Code::

public class AccountNumberFormFieldValidator implements FormFieldValidator {

private static final String PATTERN = "[0-9]+";

public boolean validate(Object submittedValue, FormFieldValidatorContext validatorContext) {

	Map<String, Object> formValues = validatorContext.getSubmittedValues();
	System.out.println(" formValues" + formValues);
	if (submittedValue instanceof String) {
		String string = (String) submittedValue;

		return string.matches(PATTERN);
	}

	return false;
}

}


#4

Oh, I am sorry I thought we are talking about doing this whole thing in modeler or generated task forms.
Unfortunately, I do not know how to do this in java.