Check multiple fields with 1 rule?

Forums Dynamic Forms for SharePoint Check multiple fields with 1 rule?

Viewing 5 reply threads
  • Author
    • #9284

      Just wondering if this is possible.

      So I already have one rule that states if I set a field to one of 2 options, that it makes 5 other fields required. I was looking into making an alert with a 2nd rule, but it looks like I’d need to make 5 different rules for each field to check if it’s empty.

      Is there any way to do this in the “rules” section, or will I need to create a custom JS function for the rule to check true/false? If so that’s fine, just want to stick with rules if possible.


    • #9297
      Alexander Bautz

      Can you tell me some more about the alert? – how is it supposed to trigger?

      If we must use a custom function, this can be written in the custom js textarea, and called from a function with a trigger “custom javascript function”.

      If you have some more details, I’ll help you with the function.


    • #9312

      Sure thing! The trigger is:

      If field “Status” is equal to “Resolved|Closed”
      Triggers on field change

      The rule makes the following fields mandatory:
      Primary Issue
      Secondary Issue
      Service Category
      Root Cause

      Currently, no matter whether those fields are empty, it pops up the alert if you changes the “Status” field to “Resolved” or “Closed”. Of course this makes sense based on the rule, but I’m looking to trigger the alert only if “Status” is changed and any of the 5 fields are empty (without making 5 more triggers).

      Let me know if you need any more info, and thanks so much for offering to help with the function if necessary! 🙂

    • #9359
      Alexander Bautz

      Sorry for the delay. Here is a solution that involves adding one function to the “Custom JS” textarea:

      In you rule, add this function name in the “Run these functions / trigger these rules” field:


      Then add this function to the “Custom JS” textarea:

      function checkRequiredFields(ruleID){
      	var a = true;
      	if(ruleID === "myTestRule"){
      		var arr = ["Field1","Field2","Field3"];
      			if(getFieldValue(f).length === 0){
      				a = false;
      				return false;
      			alert("You must fill in all fields");
      			// Optionally use the DFFS alert
      			//spjs.dffs.dlgBox("You must fill in all fields",true);

      You must change “myTestRule” to the “friendlyName” of your rule, and “arr” to contain your fields.

      Let me know how this works out.


    • #9379

      Hey Alex!

      I’m getting the following error when I call the function:


      NEVERMIND! I’m an idiot who didn’t use the internal field name. All good now! 😀

      • This reply was modified 7 years ago by Bloodlvst.
    • #9384
      Alexander Bautz

      I’m glad you figured it out.


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