Home › Forums › Classic DFFS › Need help with rules / linked rules
- This topic has 1 reply, 2 voices, and was last updated 3 years, 8 months ago by Alexander Bautz.
-
AuthorPosts
-
-
March 3, 2021 at 19:14 #32913
Hello,
I’ve been trying to set up something that I feel like should be relatively simple, but I am having problems. I think I am using the Linked Rules incorrectly, but I am looking for help on how to set these rules up.
This is in the Edit view of my form. I have a PR Completed Data field at the bottom of my form. I want this field to be read only if certain fields aren’t completed. The user should have to complete the following fields before entering the PR Completion Date:
- Customer Outreach Start Date
- Customer Outreach End Date
- Escalation 1 Resolved Date
- Only if the Escalation 1 Start Date was filled
- Escalation 2 Resolved Date
- Only if the Escalation 2 Start Date was filled
Right now, I successfully set up the first two bullet items. The PR Completed Date becomes read only when either of those fields are blank. It works but I feel like I am doing it the wrong way or the long way.
I set up 4 rules (two for each field),
- one to check if each field is blank (no action, just the test)
- one to check if it’s not blank (runs calculation described in #3 below.
- a fifth rule which checks under Linked Rules and Functions if either Customer Start Date or End Date are blank and if so makes PR Completed Date read only.
All rules are set to validate on Form Load and Field change. I had to put in the rule in number 2, because if the test from 1 came back false (if the rule wasn’t empty) nothing was happening. Rule reversing didn’t seem to work here.
So my main question: How do I set up the other bullet points using rules? I tried to set up a test to see if Escalation 1 Resolved Date was empty and Escalation 1 Start Date was filled, then another rule to set the PR Completed Date to read-only if Resolved Date was empty, and Start Date was not empty, but it just wasn’t working right.
I know it’s pretty messy to try to describe here, so please let me know what you need to help me figure this out. Thank you all in advance!
Attachments:
-
March 3, 2021 at 19:49 #32916
Hi,
This kind of multi-rule checks are easier to do with custom js. Here is an example with three date fields named “DateColumn1”, “DateColumn2” and “DateColumn3” – change the field internal names to match yours.You don’t need any of the rules – just drop this in your custom js:
(function(){ var arrToCheck = ["DateColumn1", "DateColumn2"]; spjs.dffs.doReadOnly(["DateColumn3"]); var isReadonly = true; setInterval(function(){ var pass = true; jQuery.each(arrToCheck, function(i, fin){ if(String(getFieldValue(fin)) === ""){ pass = false; return false; } }); if(pass && isReadonly){ spjs.dffs.undoReadOnly(["DateColumn3"]); isReadonly = false; }else{ if(!pass && !isReadonly){ spjs.dffs.doReadOnly(["DateColumn3"]); isReadonly = true; } } },1000); })();
To have multiple checks like in our example just repeat the snippet with a new set of field names.
Let me know how this works out.
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.