Rule for requiring a dropdown to be selected


Badge +3

I am trying to make an Approval Status dropdown box required to be filled out. I have created a rule for this

and(isNullOrEmpty({Self}), not(equals({ItemProperty:Form_x0020_Status}, "Creation")))

but I am not sure why it is not working. I only want the Approval Status to be required, if it's not in the Creation form status. Once someone submits a form, I want a manager to go in and change the Approval Status but right now it is not being required.

Here is what the form looks like below:

196937_pastedImage_1.png


11 replies

Userlevel 5
Badge +14

is it NEW form?

if so, item fields are not populated in NEW form yet, just after you submit the form.

Badge +3

No, the Associated Template and Approval Status fields show up after it has been submitted. The above view is what the manager would see when they go in to approve or deny the request.

Userlevel 5
Badge +14

so is it task form?

what's datatype of FormStatus field (text, choice, lookup ...)?

how/where do you populate value to the field - form/workflow?

have you checked it really contains value you expect?

have you test rule in preview or in runtime?

Badge +3

I'm a little confused on what you mean if it's a task form or not.

The Approval Status dropdown is a Choice and I have my three choices in the list: Approved, Denied, Cancelled. As seen below

196991_pastedImage_1.png

Yes, the field does have data in it.

The strange thing is, I have the same rule setup for Associated Template to be required as well but this one is working correctly, while the Approval Status one is not making it required. I have tested this. See the below:

196992_pastedImage_2.png

Userlevel 5
Badge +14

I'm a little confused on what you mean if it's a task form or not.

task form = form configured within workflow's task action (flexi task, request review, etc)

The Approval Status dropdown is...

sorry, I asked for datatype of FormStatus list field - the one used in validation formula.

  I have the same rule setup for Associated Template

is it one rule assigned to two form controls, or are they two rules, one for each control but with same/similar validation formula?

have you copied the formula over?

are you sure the validation message for associated template control comes from validation rule? it looks much like some default message, eg for mandatory columns.

Badge +3

No, it is not a task form. The rule is not applying on the EDIT form of the list template.

Form Status is a Choice field which defaults to Creation. After the form is submitted, a workflow runs and changes the value to Submitted. So we are trying to get certain fields to only be required AFTER the form has been submitted the first time.

There are two separate rules, however, the validation formula is the same for both. To clarify, I have the following formula used in a validation rule on our Associated Template and Approval Status fields:

and(isNullOrEmpty({Self}), not(equals({ItemProperty:Form_x0020_Status}, "Creation")))

This formula is working in our validation rule on Associated Template, which is a List Lookup. However, this formula does NOT work in our validation rule on Approval Status, which is a Choice field.

Yes, I verified the message is coming from the validation rule and is not the default message.

197012_pastedImage_1.png

As you can see in the picture above, I added "!!!" to the end of the message.

Userlevel 5
Badge +14

ok, let's try following

- place 6 calculated value controls on the form and set their formulas as follows (create all the formulas with formula builder, do not copy them over from this post nor among single formulas!)

- ApprovalStatusControl (named control)

- isNullOrEmpty(ApprovalStatusControl)

- {ItemProperty:Form_x0020_Status}

- equals({ItemProperty:Form_x0020_Status}, "Creation")

- not(equals({ItemProperty:Form_x0020_Status}, "Creation"))

- and(isNullOrEmpty({Self}),not(equals({ItemProperty:Form_x0020_Status},"Creation")))

Badge +3

I tried the 6 calculated value controls you provided above. The 5th one in order does not seem to work. Below is snapshot of the formula I used and the second snapshot is the preview of it that does not provide a value.

197043_pastedImage_2.png

197044_pastedImage_3.png

In the picture below, we cannot use "Self" under Named Controls since it's not in the list. We can use this function under Rules but don't think it's available under Calculated Values.

197045_pastedImage_4.png

Userlevel 5
Badge +14

I think it's 6th formula that gives value error. first one gives no output so you can not see it - try to enable borders for single controls and you will see that.

sure you can not use {Self} in calculated value control, I've just forgotten to replace it wih ApprovalStatusControl.

so the formula should look like

and(isNullOrEmpty(ApprovalStatusControl),not(equals({ItemProperty:Form_x0020_Status},"Creation")))

from the results I see evaluation works correctly.

your testcase is for FormStatus=='Creation', result of overall formula is FALSE, ie. form is valid and form submit passes through.

if you tested for different FormStatus, overall formula would evaluate to TRUE hence form is invalid and you get validation error as per your requirement.

Badge +3

Thanks on your suggestion for using the calculated column to see what was actually being stored in Approval Status when we thought it was empty. We found out the null value was actually stored as "**SelectValue**". We were able to change our validation rule to be the following:

197046_pastedImage_1.png

Here is where the Approval Status is now required!

197048_pastedImage_4.png

Thank you very much on all the help! happy.png

Userlevel 5
Badge +14

great you make it working!

one extra tip

no value selected interfere here between nintex and sharepoint.

if you configure choice control to take sharepoint's default value, then when you open new item, then display value is set to 'Please select' and real value to "**SelectValue**", hence isNullOrEmpty() returns false.

however, if you change control's value to 'please select' (aka no option selected), real value is empty and isNullOrEmpty() returns true (tha't I guess the case from your previouis post)

so a bit inconsistent behaviour  for the same 'Display value'

so in order you need not make validation formula more complex, I would suggest to consider setting some non-empty default value, either in list on control. or if you insist on no value preselected then force it in control's setting.

Reply