I have an Integer field created (Integer_fld) and would like to create a trigger that checks for duplicate values for previous created items items.
I tried a script from a previous discussion, but could not make it work. I thought I would start a new discussion for this.
List of Items
ID State Integer_fld Txt_fld
100 Initiate 10023 Some text here...
101 Initiate 10024 Some more text here...
I create a new Item ID 102 and for the Integer_fld I enter 10023. When I try to save it I would like to see an error message stating it is a duplicate. ID 100 has the same value in the Integer_fld.
there is another post that already covered this problem
Can you specify whether your current problem is different?
I started a new discussion because the script from that discussion did not work for me. I tried the one attached to the discussion. I'm simply trying to compare an Integer field of a new issue compared to all existing issues. The comparison would check for duplicate and if there was an error message would be displayed. This would obviously be a pre-event trigger.
I thought this would be easy and someone might have a workable solution. I believe my use case example provides enough information.
I'm assuming that the problem here is that this code compares strings and you are looking to compare integers.
Produces a query that reads: if (field[ExistingStringValue]="InputStringValue") ...
Working with integers, I'd use something more like: if (ExistingIntValue.equals(InputIntValue)) ...
Try rewriting the query building lines to work with integers instead of strings and it should work for you.