cancel
Showing results for 
Search instead for 
Did you mean: 

Using validation rules to ensure a comments box is not left empty

Not applicable
25 59 52.1K

The Scenario: When a task is rejected, ensure the user cannot submit before including a comment.

 

Crestan, a business management company has discovered an issue during their annual business systems audit. Approval tasks for system documentation have been completed and marked as rejected by some managers and employees without feedback or a given reason. The General Manager has asked you to modify the form so if a task is rejected, the user must fill in the comments field.

 

This scenario is only applicable to the Request Approval workflow action, and is applicable to both Nintex Forms 2013 and Nintex Forms 2010.

 

Validation Rules were introduced in Nintex Forms released on 5th June 2014.

Nintex Forms 2013 v2.3.2.0

Nintex Forms 2010 v1.5.2.0

 

Requirements

  • A user must be forced to enter a comment if they reject a task
  • The comment cannot be a blank value or whitespace

 

Outcome

The comments box will display a red border and a message will display if the task was rejected and comments have not been entered.

 

Configure the Nintex Task Form

For the purpose of this example, we will modify the Nintex task form within a Nintex Workflow 2013 Request Approval Action.

 

  1. In the Workflow Actions toolbox, select the User Interaction toolbox.
  2. Drag a Request Approval action onto the design canvas.
  3. Double- click to open the dialog box. In the Ribbon, click on the Edit Task Form and select Edit with Nintex Forms.

task form.png

Add a Rule

Select the Comments text box of the task form so we can add a rule to this control and click Add Rule in the Ribbon.

comments.png

formatting.png

 

Give the rule a Name “Not empty when”, and select the Rule Type as Validation.

 

In the Condition field, click on the Formula Builder icon. Select the Runtime Function “isNullOrEmpty”, and in the () select the Named Control, {Self}. This means “if the control on which this is running is null or empty…”

 

isNullOrEmpty({Self})

 

Next we add another condition to the formula when the outcome is rejected. Add “&&” and then in the Named Control tab, select Decision. The value for reject is 2, and for approve 1, so need to add ==”2”.

 

To find this value, you need to publish the workflow, then run it and use the F12 developer tools of your browser to find the values on those radio buttons.  If you check this value using F12 developer tools in the Nintex Forms preview, you will see both show as -1 values, this is incorrect when published and should be Reject=2 Approve=1.

 

The final formula should look like this, and means “this control is invalid if this field is empty and the outcome is rejected”.

 

isNullOrEmpty({Self}) && Decision=="2"

 

In the Message field, enter a message for when the form cannot be submitted.

 

 

 

 

 

 

Save the form. Now, when a user rejects a task, and tries to submit without providing a comment, a red line will appear around the comments section, and the message will appear at the top of the form.

form.png

For more examples:

Validation Rules and the People control - Nintex Forms

How to complete Date Validation using Nintex Forms 2013 Validation Rules

Formatting vs Validation Rules in Nintex Forms

59 Comments
Not applicable

Hi Emily, great post, exactly what I'm needing to do.   I run into a problem when I use the "Decision" Named Control.  It breaks the javascript for some reason.  It's like it is not recognizing it as a javascript entity even though I'm definitely using that control.  Any ideas or suggestions on debugging?

Not applicable

It turns out that the value for Decision in my case was 10 for reject and/or 9 for approve instead of 1 and 0.  Not sure yet why those values would have changed, but wanted to pass this on for anyone else that might run into this.  

Also, the form preview doesn't always "tell the truth" about the way the form will work in the actual workflow.

Thanks again, this article definitely saved me some time.

Not applicable

Glad to hear you got it working!

ianhall
Nintex Newbie

Hi,

Should the Rule Type drop down be visible in Nintex Forms 2010 v1.5.2.0 as shown above. I don't get that option.

Cheers

Ian

Not applicable

Hey Ian, validation rules were introduced in NF2010 v1.5.2.0 so you should see the drop down option, so it may be something spcific to your environment. It'd be best to contact Support so they can look into it for you. You can log a Ask Support‌ ticket here (you'll need to be signed into the community site). 

Cheers 

Em

sharepointfranc
Nintex Newbie

Good illustration of using the Validation Rules, would you have any suggestion how to validate this rule ONLY if a Submit button is pressed ? 

(since the button changes the value of a list column and not a control, we cannot get its value before form is submitted)

thanks

Francois.

Not applicable

Francois Souyri‌ - could you post your question in the Learn More‌ area - you'll have more eyes on it from the rest of the community too

sharepointfranc
Nintex Newbie

thanks Emily, I did but had no responses yet so I responded to this one hoping....

Using Validation rule to enforce fields depending on a button

michellepm
Nintex Newbie

Hi there

I tried following the above step to making comments box mandatory but no luck I don't know if there is anything am doing wrong

Even tried this blog: http://stackoverflow.com/questions/5727978/nintex-workflow-2010-make-comments-mandatory-in-flexi-app...

Would appreciate any help

Thanks

sharepointfranc
Nintex Newbie

Need more info Michelle, do you see any Javascript error, have you tried with a simple list and only 1 field ?

screenshot ?      

michellepm
Nintex Newbie

No am not getting any JavaScript error, Yes I tried it on simple form just a simple flexi task with the default nintex form form
I also added a Calculated value on the form to see what the values for the decision is and its returning -1 for both "reject" and "approve"

shyamshinde08
Nintex Newbie

The Decision value returned in my case is also -1 for both "Approve" and "Reject".

Michelle Modikoe‌ - Did you find any solution to it?

Regards,

Shyam

michellepm
Nintex Newbie

Shyam Shinde‌ -  nope I did not get any solution regarding this!

Not applicable

Hi,

Can you let other's know how you found the values for your decisions codes?  It will be helpful in setting up rules for validation.

Thank you,

Jennifer

Automation Master
Automation Master

I found in my environment, I had to use 1 for approve and 2 for reject.

To verify, I did View Source to the page and found data-nfChoiceValue for the selections.

Version 2013 3.1.1.0

mlauer
Nintex Newbie

This scenario is not only applicable to the Request Approval workflow action, it's also applicable to the Assign Flexi task action!

Not applicable

This is the exact issue I'm having as well.  Both "Approve" and "Reject" are valued at -1.  I submitted a support request to hopefully get an answer.  We are using version 3.1.4.0

Not applicable

Andrew this is correct, I have updated the documentation to reflect this.

Approve=1, Reject=2

Automation Master
Automation Master

Great! Thank you for reviewing it

Not applicable

Testing it on a live form rather than in preview and setting Reject to “2” did the trick.  Thank you!

Not applicable

Hey Jennifer, Sean Fiene​ has just published a post on this Task Form Outcome Conditional Formatting/Validation

Not applicable

Hey Robyn and Michelle Modikoe - Sean Fiene​ just published a post on this Task Form Outcome Conditional Formatting/Validation 

kristig
Nintex Newbie

How does this work with O365 and there are two different panels/tabs that require this functionality. I cannot get it to work without one overriding the other. I have a post on this already.

Automation Master
Automation Master

Hi Kristi, please link the post here and we can comment directly to it.

kristig
Nintex Newbie
DrewA
Nintex Newbie

HI. I'm new to Nintex forms. Is there a rules syntax primer available online?  I am struggling with building a valid rule using the f(x) UI panel for creating a rule.

Not applicable

I am trying to set up a simple validation based on a lookup control value selected but it wont work.  I just want to make my comments box require data if  "Other" is selected from the lookup list.  Are validations set up differently on lookup controls? I have no problems setting them up on standard choice controls

Automation Master
Automation Master

Drew, see if this reference guide can help Quick Reference of Form Validations and Expression Operators . If not, post a question on the forum and we will try to help out!

Automation Master
Automation Master

I believe you can do this as I know you can with lookup controls that are not site columns but field controls. See the following for a walkthrough Re: Forms field lookup limitation

DrewA
Nintex Newbie

Perfect! Thanks Andrew. I've bookmarked that page.

Not applicable

Hi Andrew

I read through the document but couldn't really relate it to why my validation wont work (sorry I am really new to this).  I have a look up control in my form called Device Type that is connected to another list that holds the available options.  This part works and they display in the form fine.  However when I try to reference the lookup control in my validation it doesn't work.  I just want to make the comments box on my form invalid unless it contains data if Other has been selected as the device type.  This is the condition I am using which works whenever I use it on a normal choice control .  Is it because my lookup is referencing a list and not a column?  Im trying to use a list on the same site as we want the owners to manage the list to update as required rather than having to manage it via the form control options

and(DeviceType=="Other",or(Comments==""))

Automation Master
Automation Master

I recommend that you post a new question and we can discuss it there. It will also make the question more visible to others to help out. When you do, describe more about the lookup. It now sounds like you are using the List View control and not a List Lookup control (that only brings back a column). Is this true?

christopher_lop
Nintex Newbie

same issue I'm a having as well. I added a new outcome i.e., Return and it gave the same id i.e., -1

Have you found your way around this?

Automation Master
Automation Master

Are you viewing this in Preview mode or after the form is published and running the workflow? In Preview mode you will always see it as -1.

christopher_lop
Nintex Newbie

in preview mode.

Using formatting rule to hide the comments field (just to test, but my intent is to validate)

Formula is Decision == -1

clicking on both Approve and Reject hides the comment field

I have not tried publishing it yet as I'm not getting the result I want in preview mode.

many thanks

Automation Master
Automation Master

Ok, at least this is expected. Your rule is probably correct. Please see the note above in the article about testing in Preview Mode. The result will not be able to be changed to 1 and 2 while in Preview mode.

To find this value, you need to publish the workflow, then run it and use the F12 developer tools of your browser to find the values on those radio buttons.  If you check this value using F12 developer tools in the Nintex Forms preview, you will see both show as -1 values, this is incorrect when published and should be Reject=2 Approve=1.

christopher_lop
Nintex Newbie

got it! many thanks for your help. it works now

The key point there is, it will not work in preview mode.

Reject=2 Approve=1

daveg00
Nintex Newbie

From another newbie, for what it's worth, I have a different way to achieve same result.  I have got a 'Decline' button (rather than option control and 'OK' button) that is disabled when comments are not entered.  Under the button are the words 'You must enter comments in order to Decline'.  Of course rules are applied to achieve all of this.

Not applicable

I did eventually find a solution to this.  The returned values were in another list and I needed to include the ID of the lookup list item in the validation which was located by viewing the properties of the item itself and examining the url of that page to get the number and it works now

Thanks

jacobarn
Nintex Newbie

I'm trying to make a field required when it and another field is blank. This is what I have entered in the condition: 

isNullOrEmpty(UPCCode) && isNullOrEmpty({Self})

However it's not firing at all even when both are blank.

Automation Master
Automation Master

In some scenarios, using UPCCode=="" may work better. And if you are checking that it is required based on another field then you may not need the second test.

ohagas
Nintex Newbie

This is great, thanks for sharing. I managed to get the rule working on the People picker control. However I have noticed that the rule won't work on the legacy People Picker V1. Anyone know of a workaround? The legacy people picker is required in my case as the user won't know who's in the people group

Thanks

bimi82
Nintex Newbie

Feedback:

I am running Nintex 2016 Version: 4.3.0.11 and this method does not work.
Anybody else had same issue and how to solve the problem that the Comments box NOT to be empty?!

Automation Master
Automation Master

As far as I know, there is no guarantee that the Approval value will equal 1, and the Rejection value will equal 2, and that might be causing this to not work. 

Could you test your rule with the following code instead. 

isNullOrEmpty({Control:Self}) && NWF$("[data-controlname='Decision'] input:checked").siblings("label").text() === "Rejected"
bimi82
Nintex Newbie

When I create a custom form in Nintex, I save / export it as a template and reuse it back on other forms.

Now. the strange part is that the comment validation did NOT work when I imported the form.

However, using its default form > the comment validation with isNullorEmptu({Self}) worked perfectly.

I tried bits and bobs to figure out what it is causing that behaviour but did not find anything related.

As an end result, I had basically to re-create the layout.

I am now using the latest export file and it sees to be working fine ....

One of the things ... it is just :/ annoying.

Automation Master
Automation Master

Yeah. I believe that you are running into the thing that I am talking about. The numeric values behind the Approved / Rejected buttons are generated during the creation of the form, and I wanna say that in the past, the values might not be generated as something that is predictable. 

It was something that was testable using a calculated control that just referenced the Decision control as the formula, and actually running the task to see which values appeared for which buttons, but that is a pain in the neck. 

Any who. Glad to hear that you were able to get your forms working. 

If you run into something like that again, try the code I suggested as it should work out of the box. 


bimi82
Nintex Newbie

I shall try your code next time I come across the same problem.

Although I did check via F12 to see what value is assigned to Approve value=3 and Reject value=4.

Neither them worked ... lol anyway  cheers for ur input.

isabelchen
Nintex Newbie

I have the exact same issue.  I followed the steps posted at top to set a validation rule like this:

isNullOrEmpty({Self}) && Decision=="18" 

I found the decision value via F12, which is 18. (there are 3 decision choices, the value is 18, 19, 21.  The first choice is the one I put condition on).

But it does not work.  I can still save the task form with the comments box empty.

Can anyone give a tip?

Automation Master
Automation Master
isabelchen
Nintex Newbie

When I click the link you provide, it went to the same page.  I did try your solution with this formula, but it did not work either:

isNullOrEmpty({ControlSmiley Frustratedelf}) && NWF$("[data-controlname='Decision'] input:checked").siblings("label").text() === "Rejected" 

of course I put the lable used in my form.  I can still save the form while leaving the box empty