1
0
-1

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? 

    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -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?

       

       

      import java.util.Arrays;
      import org.joget.apps.app.service.AppUtil;
      import org.joget.apps.form.model.Element;
      import org.joget.apps.form.model.Form;
      import org.joget.apps.form.model.FormData;
      import org.joget.apps.form.service.FormUtil;
       
      public boolean validate(Element element, FormData formData, String[] values) {
          boolean result = true;
       
          //get field 1 value from form data object
          String field1Id = "field1";
          Form form = FormUtil.findRootForm(element);
          Element field1 = FormUtil.findElement(field1Id, form, formData);
       
          if (field1 != null) {
              //get value of field 1
              String[] compareValues = FormUtil.getElementPropertyValues(field1, formData);
       
              //compare the value of field 2 and field 1 are equals
              if (!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
          }
       
          return result;
      }
       
      //call validate method with injected variable
      return validate(element, formData, values);
      1. 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.

      CommentAdd your comment...
    2.  
      1
      0
      -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.

        CommentAdd your comment...