Automate

 View Only
  • 1.  Missed Requirement Validation

    Posted 09-16-2020 17:48
      |   view attached
    Hi Everyone,
    I am looking to wrap a missed requirement validation rule into a button. The reason being, I have tables that have required inputs, and a button that will move to the next section, making the just completed section read only, all in the same view. The reason I mark the section read only is due to having a copy table rule that brings inputs down to the table in the section that opens up.  I need to have the section validated that all required inputs have been completed, before it changes to read only. I have included screenshots of the form and button to hopefully help show what I am trying to do. 

    Current button action......this works as designed, it asks a question, if the answer is NO, there is no action, if the answer is YES, the section is marked read only and the next section opens up for inputs. 

    debugger;
    if ($form.getValue('/my:myFields/my:Helper_Fields/my:Helper_MovetoBasic') ===''){
    jQuery.confirm('Have all necessary materials been added and required inputs been completed? If not, click "No" and complete the section. Once "Yes" is chosen, this section will be disabled and no further additions or changes can be made. If edits are necessary after this section is disabled, the edits can be made in the New Materials section below.','Inputs Complete',
    function() {
    $form.setValue('/my:myFields/my:Helper_Fields/my:Helper_MovetoBasic','X');
    $form.showGroup('grpname:Basic_Details');
    });
    }

    What I need.....is that same rule above, to include a validation that all required inputs have been completed. If not, then some sort of flag should be thrown or it breaks the yes/no function so that the user can input the missing requirement. I am really struggling with getting this right. Any help is greatly appreciated. 

    Adjusted rule currently not in use as it does not work
    debugger;
    if($form.getValue('/my:myFields/my:Instrument_Type') == '' || $form.getValue('/my:myFields/my:Reagent_Type') == ''){
    var counter = 0;
    for (var i=0; i <count('/my:myFields/my:Material_Details/my:Repeating_Content/my:MD_MatNumber'); i++){
    if($form.getValue('/my:myFields/my:Material_Details/my:Repeating_Content['+i+']/my:MD_CO') === '' || $form.getValue('/my:myFields/my:Material_Details/my:Repeating_Content['+i+']/my:MD_ChangeMaster') === '' || $form.getValue('/my:myFields/my:Material_Details/my:Repeating_Content['+i+']/my:MD_Stage') === '' || $form.getValue('/my:myFields/my:Material_Details/my:Repeating_Content['+i+']/my:MD_Division') == '' || $form.getValue('/my:myFields/my:Material_Details/my:Repeating_Content['+i+']/my:MD_MatNumber') == '' || $form.getValue('/my:myFields/my:Material_Details/my:Repeating_Content['+i+']/my:MD_MatDescription') === '' || $form.getValue('/my:myFields/my:Material_Details/my:Repeating_Content['+i+']/my:MD_Obtained') === '' || $form.getValue('/my:myFields/my:Material_Details/my:Repeating_Content['+i+']/my:MD_MatType'));{

    jQuery ("Missed a required field");
    break;
    }
    else if(count('/my:myFields/my:Material_Details/my:Repeating_Content/my:MD_MatNumber') > 1 || (count('/my:myFields/my:Material_Details/my:Repeating_Content/my:MD_MatNumber') == 1)) {
    counter = counter+1;
    }
    if(counter >= count('/my:myFields/my:Material_Details/my:Repeating_Content['+i+']/my:MD_MatNumber')){
    }
    }
    if ($form.getValue('/my:myFields/my:Helper_Fields/my:Helper_MovetoBasic') ===''){
    jQuery.confirm('Have all necessary materials been added and required inputs been completed? If not, click "No" and complete the section. Once "Yes" is chosen, this section will be disabled and no further additions or changes can be made. If edits are necessary after this section is disabled, the edits can be made in the New Materials section below.','Inputs Complete',
    function() {
    $form.setValue('/my:myFields/my:Helper_Fields/my:Helper_MovetoBasic','X');
    $form.showGroup('grpname:Basic_Details');
    });
    }}

    Thank you!

    ------------------------------
    Vanessa Kutasi | Application Analyst II
    IDEXX | New England WUG Leader
    ------------------------------

    Attachment(s)



  • 2.  RE: Missed Requirement Validation

    Posted 09-18-2020 13:49
    Hi Vanessa -

    I'm not sure if it's an option or if you've tried it already, but is it possible to hide the button until all data requirements have been met?

    Thanks!

    ------------------------------
    JENNIFER HWANG | SE
    Winshuttle North America
    ------------------------------



  • 3.  RE: Missed Requirement Validation

    Posted 09-21-2020 10:21
    Hi Jennifer, 

    I have not tried your suggestion but I am thinking it may be an easier path. Would the rule be similar? Or would it be a custom var rule to verify each row is not blank (it would be looking at a repeating table). If criteria met, show button?

    ------------------------------
    Vanessa Kutasi | Application Analyst II
    IDEXX | New England WUG Leader
    ------------------------------



  • 4.  RE: Missed Requirement Validation

    Posted 09-21-2020 15:01
    Hey Vanessa -

    Yep, you've definitely got the general idea. 

    Here's one example of how to handle this. You will need 2 helper fields. One is just a standalone text field (let's call this ConcatenateHelper). One will be another column in that table, which defaults to false (let's called this ColumnHelper).

    In each of your Material #, Description, How obtained, and Type fields, you will have the same rule in them (just copy and paste in each) that says if Material # is not blank and Description is not blank and How obtained is not blank and Type is not blank, then set field ColumnHelper to true.

    In ConcatenateHelper, its default value will be the concatenation of the ColumnHelper values.

    You will hide the button by default. Then you will only unhide the button if ConcatenateHelper does not contain false. 

    Hope this helps!

    Thanks!

    ------------------------------
    JENNIFER HWANG | SE
    Winshuttle North America
    ------------------------------



  • 5.  RE: Missed Requirement Validation

    Employee
    Posted 09-22-2020 10:03
    Hi Vanessa

    Here's what I would do.  I just tested out my theory in Evolve, and it should work similarly in Foundation
    • add a field to your row as a helper field - I used a boolean flag
    • add a rule to each required field in the table that if all fields are not blank, set the flag to true.  If you have a lot of required fields, that will be a big IF

                make sure you add the reverse rule, as well - if field1 or field2 or.... is blank, set to false
    • add a count field outside of the table and use a COUNT as the default, check the refresh default.  the COUNT would use a field name in the table


    • add a count field outside of the table to count rows that have all required fields filled in.  Put a rule on your helper field/flag to set the number of rows that have all required fields filled in


    You'll end up with something like this
    You can put a rule on the count field that has required fields filled in - if equal to the number of rows, show a button, do an action, whatever it is you want to do.

    Hope that helps,
    Sigrid

    ------------------------------
    Sigrid Kok
    PSE | Winshuttle NA
    ------------------------------



  • 6.  RE: Missed Requirement Validation

    Posted 09-28-2020 16:34
    Hi Sigrid,
    I have implemented the fields and rules as you had outlined, but am getting stuck on a single input. This input is only required when the field is enabled. I have a rule that checks if it is enabled or disabled and sets the correct status (required/not-required). I need to incorporate this input into the overall validation. I have added the disabled/enabled check into the overall "all requirements met" rule, but it doesn't trigger appropriately. Both rules are attached (the rule validating if it's required or not, and the rule checking that the requirement has been met. I have also included a screenshot showing that both rows are valid and should be setting the "All Req. Met" flag. 

    Any thoughts on this one?

    This is a repeating table, so it needs to validate each row. 

    Thank you!

    ------------------------------
    Vanessa Kutasi | Application Analyst II
    IDEXX | New England WUG Leader
    ------------------------------



  • 7.  RE: Missed Requirement Validation

    Employee
    Posted 09-28-2020 17:06
    Hi Vanessa

    So as you can tell, I'm not using Javascript.  I tried to imagine what you meant by purchased material, so I came up with this based on material type but use the fields of your choice
    If HAWA, field1, 2 and 3 all have to be filled in to be considered "complete"
    If not HAWA, field 1 and 2 have to be filled in to be considered "complete"

    rules on all 3 fields, field1, 2, 3

    two true rules
    two false rules - please notice the groupings with ANDs/ORs.  So MatType = HAWA AND (field1 is blank OR field2 is blank OR field3 is blank) and MatType != HAWA AND (field1 is blank OR field2 is blank)

    I'd attach my solution, but again it's in Evolve.

    Hope that helps.

    Best Regards,
    Sigrid

    ------------------------------
    Sigrid Kok
    PSE | Winshuttle NA
    ------------------------------



  • 8.  RE: Missed Requirement Validation

    Posted 09-29-2020 08:02
    Ugh, so simple! I don't know why I didn't think to reference the field that implicates being a purchased material. We have a selection that asks how the material is being obtained (Purchased, MFG in House or Subcontracted). 

    I am using JavaScript due to it being a repeating table, which is initially populated using the copy table data functionality.  I have updated the rules, including not being JavaScript and they work as I need them to. 

    Thank you! Sometimes the most simple path is hardest to see. 

    I appreciate both Your and Jennifer's assistance with this. :)
    Requirements Met Accurately


    ------------------------------
    Vanessa Kutasi | Application Analyst II
    IDEXX | New England WUG Leader
    ------------------------------



  • 9.  RE: Missed Requirement Validation

    Employee
    Posted 09-29-2020 08:48
    So glad it works, Vanessa!  

    Simple is best.  Although I'll admit that sometimes the behavior of the rules are not as expected, and sometimes you need Javascript.

    I create a small test solution and iteratively add rules to achieve the desired result and then try to apply in the main solution.

    Best Regards,
    Sigrid

    ------------------------------
    Sigrid Kok
    PSE | Winshuttle NA
    ------------------------------