Validate input field value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2019 02:56 AM
Hi
I have created a custom table name as badge. I have two field name as Badge type and Bagde number. Badge type is of drop down has value C1 and C2 and Badge number is of text field. When user select type as C1 then user needs to enter value in number field. Suppose user enter A6857. Now when another user select C1 and enter same value that is A6857 then it should throw an error.
How can I validate this ? Kindly help me in this.
Thanks,
Saurabh
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2019 03:34 AM
Before Insert BR on table badge
select advanced
in the script
var gr = new GlideRecord("badge");
gr.addQuery("badge_type",current.badge_type); //change the fields as per your names
gr.addQuery("badge_number",current.badge_number); //change the fields as per your names
gr.query();
if(gr.next()) {
gs.addErrorMessage("Same number cannot be sleected");
current.setAbortAction(true);
}
Mark the comment as a correct answer once worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2019 04:05 AM
Hi Asif,
Thanks for your response. I have applied this business rule but when I am entering next record it is throwing error for all records.
Thanks,
saurabh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2019 04:08 AM
Hi Saurabh,
The script basically checks and does not allow to enter a record if badge type and badge number (cobmination record) already exists.
If you do not want this, then let me know.