Rules for Drop-down Controls

Answered

Comments

6 comments

  • Avatar
    Yaniv Levi

    Hi Sylvia,

    You have few options to achieve that, I'll list two different ones:

    Option #1 - Leverage the dropdown nature to restrict values only from its available options:

    Since the standard drop down will only accept a value if it is included in its list option, you can use this with the rule builder and design a 3 step rules:

    Rule 1 - set the value of the drop down to the value in input text box.

    As mentioned, dropdown will only allow to have a value if its part of the available options, so now, the following two rules, will check if the value (or value option) equals to input text value and if so will set the output field to Yes.

    The third Rule will be used as the Else option, meaning, if the value (or value option) not equals to input text value and if so will set the output field to No.

    NOTE: For this to work, you need to make sure to check the "Execute Rules Independently".

    Here is a screenshot (toke the screenshot from the Rule Inspector, so it can all be included in the same screen shot):

    Option #2 - Use small JavaScript to check and set the result:

    You can include this small JavaScript to check if the DropDown include in its options value from the input text, and set the value to the output accordingly:

    function isContainOption(context, optionsFieldRef, refField){
        // Get the value from the Input Field (field set with the Control Rule)
        let value = $('#'+context.id).val();
        // Check if the DropDown contains the value in its options
        let exists = $('#'+optionsFieldRef+' option[value='+value+']').length > 0;
        // Set the output field with Yes/No depending on exists
        $('#'+refField).val((exists === true ? 'Yes': 'No'));
    }

    Once you added the JavaSctipt, set the input field with a control rule as follow (note - no need to pass the context variable, as it automatically passed by the invoking control):

    Hope the above options are clear and help.

    More options are available... For sample, depending on the source of your DropDown, if its from a DataSource, than would simply use an AutoLookup to check if value is included in options set the output field accordingly.

    Thanks,

    Yaniv.

    2
    Comment actions Permalink
  • Avatar
    Sylvia Able

    Yaniv,

    Thank you so much!  I tried your first option above and did get it to work...

    A couple of things tho..

    If I dragged the value of my textbox to the rule from the form data, it did NOT work:

     

    BUT, if I dragged the value of my textbox to the rule from the Fields list, it DID work:

    Is this expected behavior?  I would have thought that it did not matter.

    Another question....the compare here is case sensitive.  Is there a way to make it case insensitive?

    Thank you!

    0
    Comment actions Permalink
  • Avatar
    Yaniv Levi

    Hi Sylvia,

    First, glad it helped you.

    To your question - yes, this is expected. Here is the explanation:

    Right Side - Process Data (blue bordered on the screen shot below):

    • Fields shown on the right of the screen, under the "Process Data" (when you open the Data Draw) - represent the underlying data structure for Form Fields, Process Data, DataSource, System Data and Global Data. 
    • As for their values - for Form Fields, Process Data, DataSource it represent your current values as saved in the underlying data source... (depending on app type and primary datasources used).
    • Or to put it simply they represent what is currently saved into the "DataBase".
    • On form load - the data will be retrieved and populated onto the corresponding form controls and it will be updated back based on user edit and input when form will be Submitted (or saved when enabled and applied).

    Left Side - Fields (controls - green bordered on the screen shot below):

    • This represent the actual controls on the form
    • Values - is the actual value as currently can be seen on the form - either original value and edited value by the user.
    • Again, and to point out, this values will be saved and updated into theier corresponding fields under the "Data Draw" (right side of the screen) only when form is Submitted or Saved.

     

    Generally speaking - for the form RuleBuilder - when you want to refer (check / use - either the When or for the Action) the current value in a given control - drag it from under the Fields section on the left side of the screen.

    Hope this clear out on the difference between the two :)

    Best,

    Yaniv.

    2
    Comment actions Permalink
  • Avatar
    Sylvia Able

    Thank you Yaniv for the great explanation!

    Was there any way to resolve the case sensitivity issue?

    0
    Comment actions Permalink
  • Avatar
    Yaniv Levi

    Hi,

    For case sensitive, depending on the control type, in the operator you'll have options to ignore case sensitive:

    This will not be available for DropDown control (we'll check to enhance this).

    If you'll go with the JS options, this can be easily achieved. If not, than you can use the formula field to turn your input to lower/upper case and than follow with the rest of the rules (in that case, apply you rule on the formula field instead of the input field).

    Hope this helps,

    Yaniv.

    2
    Comment actions Permalink
  • Avatar
    Sylvia Able

    Thanks Yaniv.  It looks like there are only options for lowercase or uppercase in the formula.  Our dropdown items would be mixed case.  It appears that only javascript would suffice here.

    Appreciate your responses!

    0
    Comment actions Permalink

Please sign in to leave a comment.