I am trying to add a rule in my Nintex form, so that if someone add a value in the column it should be in a range, and if it is our of range than an error message should be appeared. Like If someone is adding an expected salary for a role, then it should be in between the min and max salary of that role.
Or(lessThanOrEqual(Expected Salary, lookup("Job Opportunities", "Role", parseLookup(Position you are applying for), "Max Salary")), greaterThanOrEqual(Expected Salary, lookup("Job Opportunities", "Role", parseLookup(Position you are applying for), "Min Salary")))
I am using this, but whenever I try to add any value whether it is in between the range or out of range error is coming up(validation message).
It would be great if anyone can help with this.
Thank you
Best answer by MegaJerk
expectedSalary >= minSalary
That's because your logic is always true, and Rules execute when the conditions therein are true!
Here is some fake example code that follows your rule logic:
var expectedSalary = 100;
var maxSalary = 1000;
var minSalary = 10;
(expectedSalary <= maxSalary || expectedSalary >= minSalary)
// break that down into numbers and you can see that both of these are true!
100 <= 1000 OR 100 >= 10
What you need to do instead is check that BOTH of the statements are true, and then reverse the result. So instead of using an Or, you'd use an And, then you'd invert it using a Not. Here is an example below that uses your rule code:
not(
and(
lessThanOrEqual(
Expected Salary,
lookup(
"Job Opportunities",
"Role",
parseLookup(Position you are applying for),
"Max Salary"
)
),
greaterThanOrEqual(
Expected Salary,
lookup(
"Job Opportunities",
"Role",
parseLookup(Position you are applying for),
"Min Salary"
)
)
)
)
So if you're minSalary is 100, and your maxSalary is 1000, and your expectedSalary is 400, then...
That's because your logic is always true, and Rules execute when the conditions therein are true!
Here is some fake example code that follows your rule logic:
var expectedSalary = 100;
var maxSalary = 1000;
var minSalary = 10;
(expectedSalary <= maxSalary || expectedSalary >= minSalary)
// break that down into numbers and you can see that both of these are true!
100 <= 1000 OR 100 >= 10
What you need to do instead is check that BOTH of the statements are true, and then reverse the result. So instead of using an Or, you'd use an And, then you'd invert it using a Not. Here is an example below that uses your rule code:
not(
and(
lessThanOrEqual(
Expected Salary,
lookup(
"Job Opportunities",
"Role",
parseLookup(Position you are applying for),
"Max Salary"
)
),
greaterThanOrEqual(
Expected Salary,
lookup(
"Job Opportunities",
"Role",
parseLookup(Position you are applying for),
"Min Salary"
)
)
)
)
So if you're minSalary is 100, and your maxSalary is 1000, and your expectedSalary is 400, then...
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.