I have a problem where users can circumvent data validation rules using certain tricks explained below. How do i restrict users from doing so.
I have a form where the user selects and item from a referenced dropdown and inputs the quantity. Only for a particular item can the quantity be greater than 1. For all other items, the quantity can only be one.
I have set the validation rule as such:
not(and(if([_Thisrow].[Item]<>"Apple",True,False),[Quantity]>1))
This validation fails when the user performs actions in this sequence:
- Select item whose quantity can be > 1
- Change quantity to a higher number, for example: 3
- Now select another item whose quantity cannot be > 1
- Saves the form.
You may want to elaborate which column you are using this validation expression.
In general, based on understanding of your requirement, you could try the below expression in the valid_if of the [Quantity] column
IF([Item]=āAppleā, [_THIS]>=1, [_THIS]=1)
Here it is assumed that only item āAppleā can have quantity greater than zero.
2 Likes
Your solution worked. But i donāt understand why it worked.
My formula was checking the validity effectively, but it could be circumvented using the process described in the original post. However, with your formula, it cannot be circumvented. I would like to know what i was doing wrong.
To answer your question, i have put the formula in the āvalid_ifā field of the [quantity] column.
Hi @munjalsavla ,
Please do not use [_THISROW] in such expression. I believe this sets references to referenced column and changing values in other referenced fields reflects only when specifically changed again. So valid_if does not kick in till the [Quantity] is changed again after changing [Item]
Please note I have not used [_THISROW].[Item]
1 Like