Handling multiple fields in rules

Forums Dynamic Forms for SharePoint Handling multiple fields in rules

Tagged: ,

This topic contains 1 reply, has 2 voices, and was last updated by  Alexander Bautz 6 months, 1 week ago.

  • Author
    Posts
  • #20301

    Hi,

    I got a form with 4 Tabs. Initially only the first tab shall be visible and as soon as all required fields are not empty the others shall be visible.

    I got it to work with one field but not that all fields must be filled. How to combine the rules so the tabs appear when all fields are filled?

    thanks.
    Christoph

  • #20324

    Alexander Bautz
    Keymaster

    Hi,
    This needs two rules and some custom js. First add two rules.

    First rule
    Rule friendly name: showTabs
    trigger: No trigger (must be triggered manually)
    Visible tabs: list of tabs

    Second rule
    Rule friendly name: hideTabs
    trigger: No trigger (must be triggered manually)
    Hidden tabs: list of tabs

    Then add this to the Custom JS:

    function showTabsWhenAllRequiredFieldsAreFilledIn(){
        var arrOfFields = ["Field1","Field2","Field3"], allFilledIn = true;
        jQuery.each(arrOfFields,function(i,fin){
            if(getFieldValue(fin).length === 0){
                allFilledIn = false;
            }
        });
        if(allFilledIn){
            clearInterval(showTabsInterval);
            spjs.dffs.triggerRule(["showTabs"]);
        }else{
            spjs.dffs.triggerRule(["hideTabs"]);
        }
    }
    var showTabsInterval = setInterval(function(){
        showTabsWhenAllRequiredFieldsAreFilledIn();
    },1000);

    Change “arrOfFields” to match your fields.

    This will check to see if all fields have been filled in every second, and when they are it will show your tabs.

    Let me know how this works out.

    Alexander

You must be logged in to reply to this topic.