Following from the first rule you used (isNullOrEmpty AND "B"), you could try (isNullOrEmpty AND ("A" OR "C")). That is:
isNullOrEmpty({Self}) && (NWF$(""data-controlname='Decision'] input:checked").siblings("label").text() === "A" || NWF$("(data-controlname='Decision'] input:checked").siblings("label").text() === "C")
I got it to work yesterday using the same formula as the first one, except text()=== “A” || “C”.
Thanks
Hi Michael,
Actually the problem still exist – the formula I used works on showing the red frame when mandatory data is missing, but after filling the required data, the form cannot be saved.
isNullOrEmpty() && NWF$("(data-controlname='Decision'] input:checked").siblings("label").text() === "Rejected" || "Not done - need more information"
Then I tried the formula you suggested, but it does not validate the required data, ie. Form can be saved while required data is missing
isNullOrEmpty() && (NWF$("(data-controlname='Decision'] input:checked").siblings("label").text() === "Rejected" || NWF$("(data-controlname='Decision'] input:checked").siblings("label").text() === "Not done - need more information")
Do you any new suggestions?
Thanks!
Firstly, in the formula you pasted, you're missing the {Self} named control in the IsNullOrEmpty() function -- I'm not sure if that's just a pasting error in your post or in your actual form design itself, so you might want to check that.
Secondly, where are you entering these validation formulae? As validation rules on the control(s)? If that's the case, then the presence of the NWF$ namespace is a bit concerning as this is usually required for JavaScript referencing and should be unnecessary for checking the value of the option selected.
Finally, without diving any deeper into your particular implementation, I just whipped up something quick in a basic form (note: this is not a Task Form, but I think the same logic should apply) to demonstrate the conditional validation on a couple of text boxes based on the option selected in a Choice control.
The Form Design
Based on your original description, I imagine there's a Choice control that allows for the selection of 1 out of a possible 3 choices. Depending on which option is selected, some "boxes" (assumed single line textbox) will become mandatory fields. The sample form appears as follows:
The relevant control properties are shown below:
Choice
Name: Decision
Required for B
Validation rule: isNullOrEmpty({Self}) && Decision == "B"
Required for A or C
Validation rule: isNullOrEmpty({Self}) && (Decision == "A" || Decision == "C")
The Result
Option A selected and "Required for A or C" is blank:
Option B selected and "Required for B" is blank:
Option C selected and "Required for A or C" is blank:
Hopefully this helps.
Thanks Micheal,
But I ended up using two rules, instead of one with “OR” to accomplish this, and it works.
Roberto, I'm on Nintex Forms and Workflows 2016 (4.3.3.0 for both), so I can't really speak to your version and its differences, if any. Also, you mention your issue is related to NW (Nintex Workflow I assume) where the above was posted in relation to validation rules on Nintex Forms.
Roberto, I wasn't doing anything specific other than creating a generic Nintex form on a generic SharePoint list for the purposes of demonstrating form validation rules as described by, and to help, the original poster. Note that the Choice control (shown above with options A, B and C) do not represent "task outcomes" which is what you might be confusing this with.
The "steps" I took to get into form designer were simply to view a generic/custom SharePoint list and click on the "Nintex Forms" button, then "Customize the Item Form". What I described above should be applicable to customised task forms as well, but once again, I have a feeling that you're trying to apply the validation rules on a Choice control to task outcomes, which I don't think will work.