Performance problems with visibility rules

Home Forums General discussion Performance problems with visibility rules

Viewing 5 reply threads
  • Author
    Posts
    • #15517
      Artaker
      Participant

        Hi!

        I have to “recreate” a form, that was made with InfoPath originally.

        The fields are easy but I’m struggeling with the visibility of the buttons.
        I created html buttons in the Tabs (there are 5) and added rules to have them visible only when the field Status has a specific value. Since I didn’t know any better way, I added a rule per status – there are 6 different status for this form, for 2 the rule are the same. Additionally I use the options given in the rules to hide the save and edit button for 4 of the 6 status.

        The thing is – when I activate these rules, it does work but the form takes forever to load (sometimes it even writes out this message). I have no errors in the f12 log.
        As soon as I disable the rules, it’s loading fast again.

        I tried those rules with only the function to hide the save/edit buttons, worked fine, can’t really tell if it was slower.
        But the more rules I activate to hide/set visible the buttons the loading gets slower 🙁

        Do you have any idea how I could optimize this, to keep the loading faster?

        Thanks
        BR,
        Nicole

        I use the “Visible headings or elements” field to refer to the elements unique ID.

        • This topic was modified 7 years, 10 months ago by Artaker.
      • #15589
        Alexander Bautz
        Keymaster

          Hi,
          Try adding all the buttons in one HTML section, and give each button an ID like this:

          <button id='rejectTravelExpBtn' style='display:none' type='button'...

          The above button has not been hidden initially with display:none, and you can use the id “rejectTravelExpBtn” in the “Visible headings or elements”.

          Let me know how this works out.

          Alexander

        • #15690
          Artaker
          Participant

            Hi Alexander!

            Thanks for the suggestion, but this didn’t really help – loading is still much slower.
            I also tried to check the “No reversing of this rule” in each rule and entered the ids of the buttons that should not be shown. Sadly this didn’t make it faster either 🙁

            Isn’t there a possibility to hide/show the buttons through one rule? Specially, since I got an additional requirement – I will have to check group membership as well. (So the visibility of the button depends not only on the status of the item but as well the current logged in user.)

            As it is now. it’s too slow and my users won’t be happy (=won’t use it)

            Any other suggestions?
            Thanks very much

            Best regards,
            Nicole

            • This reply was modified 7 years, 9 months ago by Artaker.
          • #15719
            Alexander Bautz
            Keymaster

              Add the buttons to one HTML section in your tab like this:

              <input id="btnNumber1" class="customBtn" type="button" value="DFFS Example button 1" onclick="functionNumberOne();return false;">
              <input id="btnNumber2" class="customBtn" type="button" value="DFFS Example button 2" onclick="functionNumberTwo();return false;">
              <input id="btnNumber3" class="customBtn" type="button" value="DFFS Example button 3" onclick="functionNumberThree();return false;">

              Remove all the rules you have controlling the button visibility, and add this code to the Custom JS:

              function switchButtonsByStatus(){
                  // Hide all
                  $(".customBtn").hide();
                  var status = getFieldValue("StatusField");
                  switch(status){
                      case "Not started":
                          $("#btnNumber1").show();
                      break;
                      case "In progress":
                          $("#btnNumber2").show();
                      break;
                      case "Completed":
                          $("#btnNumber3").show();
                      break;
                      default:
                          // Show a button when status is not set?
                      break;
                  }
              }
              
              // Trigger on load
              switchButtonsByStatus();
              
              // Trigger on change
              $("#dffs_StatusField").on("change",function(){
                  switchButtonsByStatus();
              });

              Please note that you must change “StatusField” to your own field name, and the “case” values to match your actual statuses.

              Let me know how this works out.

              Alexander

            • #17464
              Artaker
              Participant

                Hi!

                Sorry for the truely really late reply but I finally managed to get this implemented – and it works like a charm 😀

                Now i only need to know how to add the check for the permitted user group. Not sure if this isn’t more easy through rules..

                Thanks

                BR,
                Nicole

              • #17506
                Alexander Bautz
                Keymaster

                  To get the user groups you can use some built in functions in DFFS.

                  // Get all groups for current user
                  spjs.dffs.doLoadGroupColl();
                  // Check if user is in group bu group ID
                  if(spjs.dffs.data.uGroupColl.id["22"]){
                      //user is in group with ID 22
                  }
                  // Check if user is in group bu group name
                  if(spjs.dffs.data.uGroupColl.id["GroupA"]){
                      //user is in group named "GroupA"
                  }

                  You can wrap the show button code in this user group check.

                  Let me know how this works out.

                  Alexander

                  PS: Load time has greatly improved in the latest version of DFFS – you should check it out.

                  Alexander

              Viewing 5 reply threads
              • You must be logged in to reply to this topic.