cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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

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

Labels: (2)
Reply
58 Replies
Not applicable

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

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?

0 Kudos
Accept as Solution Reply
Not applicable

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

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.

Accept as Solution Reply
Not applicable

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

Glad to hear you got it working!

0 Kudos
Accept as Solution Reply
Workflow Hero

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

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

0 Kudos
Accept as Solution Reply
Highlighted
Not applicable

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

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

0 Kudos
Accept as Solution Reply
Workflow Hero

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

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.

0 Kudos
Accept as Solution Reply
Not applicable

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

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

Accept as Solution Reply
Workflow Hero

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

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

0 Kudos
Accept as Solution Reply
Workflow Hero

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

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

0 Kudos
Accept as Solution Reply