Skip to main content

Hi all

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

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...



expectedSalary <= maxSalary

is true



 



expectedSalary >= minSalary

is true



 



therefor: 



and(expectedSalary <= maxSalary, expectedSalary >= minSalary)

is true



 



which means that if you invert it with a not() function, then it will be:



not(and(expectedSalary <= maxSalary, expectedSalary >= minSalary))

false



 



and your rule won't run!


Thank you MegaJerk, for highlighting where I am doing an error

If this was able to answer your question, please mark it as being the solution so that this thread is flagged as solved. 



 



 


Reply