how to set the field value unique using script ?

sk227
Kilo Explorer

Hi,

i have two fields X and Y,

if my X- field has a value "123" and Y - field has a value as "456"

then my Y field should not take any other   value as "456" (for my X - field "123" ). it should throw an error as "record exist already".

Please help me out with using script.

6 REPLIES 6

sk227
Kilo Explorer

Hi Togla,


thanks for your response.


but when my X field have different value(not 123)   than it should accept Y field value as "456" .


appreciate your feedback.


tolga1
ServiceNow Employee
ServiceNow Employee

Hi Sarath


What about just adding another query condition?



gr.addQuery("X","!=","123");



Wouldn't that work? So it only searches for duplicates, where X is not 123.