Bulk adding rules?

Forums Classic DFFS Bulk adding rules?

Viewing 3 reply threads
  • Author
    Posts
    • #37311
      Jordan
      Participant

      I have a lengthy form with ~50 fields that have the same results dropdown choices, options 1, 2 or 3. If one more of the fields has option 1 selected, then I want the same action to take place.

      I know of the clone feature for rules, but is there any other ‘bulk’ option to create what will be essentially the same rule? Is there another feature in DFFS that you recommend I explore?

      Thank you.

    • #37325
      Alexander Bautz
      Keymaster

      I think this is better solved using some custom js. If you can show me how the fields are set up with the options I can give you an example of a script you can use.

      What you basically want to have is an array of all the internal names, loop over them and add an eventlistner to the click of the field and in this click function loop over the fields again to check all values – if any of them are true, trigger a rule that does what you need it to do.

      Alexander

    • #37373
      Jordan
      Participant

      Apologies for the delay.

      Example of 2 of the fields:
      FieldInteralNames: Q1_x0020_Status, Q2_x0020_Status
      Display Name: Q1 Status, Q2 Status
      Field type: SPFieldChoice
      Options (same in every field): Pass, Fail, N/A

      The trigger I am looking for is Fail.

    • #37378
      Alexander Bautz
      Keymaster

      Add something like this to your custom js:

      var arrOfFields = ["Q1_x0020_Status", "Q2_x0020_Status"];
      
      arrOfFields.forEach(fin => {
          jQuery("#dffs_" + fin + " select").on("change", function(){
              triggerChangeChoiceFields();
          });
      });
      
      function triggerChangeChoiceFields(){
          var hasFail = false;
          arrOfFields.forEach(fin => {
              if(getFieldValue(fin) === "Fail"){
                  hasFail = true;
              }
          });
          if(hasFail){
              // Do your custom action here - for example call a rule that is set up with "Not trigger (must be triggered manually)"
              spjs.dffs.triggerRule(["customTrigger"]);
          }
      }
      

      This code triggers a rule called customTrigger – set up with the trigger “No trigger (must be triggered manually)”.

      Let me know how this works out.

      Alexander

      • This reply was modified 6 months, 3 weeks ago by Alexander Bautz. Reason: Fixed code snippet format
Viewing 3 reply threads
  • You must be logged in to reply to this topic.