Home › Forums › Classic DFFS › Check multiple fields with 1 rule?
- This topic has 5 replies, 2 voices, and was last updated 8 years, 12 months ago by Alexander Bautz.
-
AuthorPosts
-
-
November 13, 2015 at 16:59 #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.
Thanks!
-
November 16, 2015 at 15:54 #9297
Hi,
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.
Alexander
-
November 16, 2015 at 22:21 #9312
Sure thing! The trigger is:
If field “Status” is equal to “Resolved|Closed”
Triggers on field changeThe rule makes the following fields mandatory:
Primary Issue
Secondary Issue
Service Category
Root Cause
OwnershipCurrently, 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! 🙂
-
November 19, 2015 at 16:08 #9359
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:
checkRequiredFields
Then add this function to the “Custom JS” textarea:
function checkRequiredFields(ruleID){ var a = true; if(ruleID === "myTestRule"){ var arr = ["Field1","Field2","Field3"]; spjs.$.each(arr,function(i,f){ if(getFieldValue(f).length === 0){ a = false; return false; } }); if(!a){ 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.
Alexander
-
November 20, 2015 at 22:09 #9379
-
November 22, 2015 at 08:51 #9384
I’m glad you figured it out.
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.