Category Archives: DFFS

DFFS Rule reversing explained

One of the main areas of confusion when using DFFS is the automatic rule reversing of rules that are NOT evaluated to true.

This example show how most users first set it up and ends up with the wrong result. I’ll first show how it is set up to make it fail, and then I’ll highlight the missing part at the bottom of this post.

The example form

Let’s say you have a choice field TabVisibility that controls the visibility of a specific tab. For this example I have created a choice field with two values: Show and Hide, an have set up three rules.

The tabs:

Tab is set to hidden but this will not work because the rules show below will override it.

The rules:

One for hiding the tab when the TabVisibility choice field is empty:

One for showing the tab when the value is Show:

And one for when the value is Hide:

This is how it looks when loading NewForm and the value in TabVisibility = blank, but it is not doing what you expect:

This must be wrong – the tab is not hidden???

Why this is not working

When you have trouble with a form you should always use the Debug this rule setting:

This will show you the debug panel below the form:

When the form loads, each of the three rules are evaluated. The first rule is evaluated as “true” and hides the tab as it should:

Hides the tab.

Then the next rule runs and is evaluated as “false” and does the opposite of what it is configured to do. It doesn’t do anything wrong here because the tab is already hidden, but you see where this is going:

Should show the tab if true, but reverses and hides the tab instead.

Then the last rule comes in and messes it up by showing the tab despite it being set up to HIDE the tab and not to show it:

Shows the tab because the rule is reversed when not evaluated to true.

Why is this happening?

The reason for this behavior is to avoid writing two rules for every action and just let DFFS handle the reversing – for example if a Yes/No field is checked: show some fields, set some fields required etc. Then if the field is unchecked, all visible field are hidden, required fields are set as optional etc. This is by design to limit the number of rules required to make a dynamic form.

This will however create problems when you use multiple rules on for example a single choice column as described above.

How to fix it

In this scenario you must use the No reversing of this rule setting in each of the three rules (optionally you can check the Disable reversing of all rules in the top of the Rules tab):

No reversing set on each rule.

When you have done this your NewForm will load correctly and hide the tab:

That’s it – post any comments below, or use the forum.

Alexander

DFFS Example: Limit access to form

This example show how you can use a set of rules to ensure only persons assigned in a people picker in the form, or members in an admin group can view or edit a list item.

Add these three rules:

This rule doesn’t have any actions.
This rule doesn’t have any actions.
This rule checks the two previous rules, and calls a function if both are false.

Then add this function to your Custom JS:

function noAccessToThisForm(){
jQuery("#part1").hide();
spjs.dffs.alert({
"title":"No access",
"msg":"You don't have access to this list item.",
"ok":function(){
window.history.back();
}
});
}

You can use this setup in both DispForm and EditForm, and it will show this message box if the user doesn’t have access:

Post any questions below, or use the forum.

Alexander