2 answers
- 10-1
Hi Walter this is the Bean Shell Code that i think use in order to validate , but i´m not sure how to do .
The principal problem is how can i do to get a value from the form and latter compare it with a field in a database?
importjava.util.Arrays;importorg.joget.apps.app.service.AppUtil;importorg.joget.apps.form.model.Element;importorg.joget.apps.form.model.Form;importorg.joget.apps.form.model.FormData;importorg.joget.apps.form.service.FormUtil;publicbooleanvalidate(Element element, FormData formData, String[] values) {booleanresult =true;//get field 1 value from form data objectString field1Id ="field1";Form form = FormUtil.findRootForm(element);Element field1 = FormUtil.findElement(field1Id, form, formData);if(field1 !=null) {//get value of field 1String[] compareValues = FormUtil.getElementPropertyValues(field1, formData);//compare the value of field 2 and field 1 are equalsif(!Arrays.equals(values, compareValues)) {String id = FormUtil.getElementParameterName(element);formData.addFormError(id,"Value not equal!!!!");result =false;}}else{//ignore if the field 1 not exist}returnresult;}//call validate method with injected variablereturnvalidate(element, formData, values);- Walter
You can use https://dev.joget.org/community/display/KBv6/Duplicate+Value+Validator without writing the code here if you need to compare duplicate vallue. However, I think that you should use options binder to show just what can be chosen, instead of trying to check what is selected can be chosen or not.
Add your comment... - 10-1
You can use bean shell options binder to set skip the value in your workflow variable and return the rest that's applicable. See Bean Shell Programming Guide#UseasFormOptionsBinder for example.
Add your comment...
HI Friends, I need add an activity to call a form that enable change to the user the value of a workflow variable but it must hide or avoid use a value that was previusly used. For example I am thinking use a radio button, if in the previus activity I did set the workflow variable a value like A, this control must only offer B and C as value.
Anybody have and idea?