- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 08:00 PM
Hi, Totally newbie here. I would like to ask how to prevent creation of a new record, if a record already existed in business rule.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 08:50 PM
Hi,
why not make the u_reference_1 field as Unique at dictionary level?
In this way no business rule is required
In case you still want to use business rule then use this
Before Insert
Script:
var gr = new GlideRecord(current.getTableName());
gr.addQuery("u_reference_1", current.u_reference_1);
gr.query();
if (gr.hasNext()) {
gs.addErrorMessage("not allowed");
current.setAbortAction(true);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 08:03 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 08:31 PM
thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 08:06 PM
Your form makes no sense as it is. If they select a user here, then a user exists, so no need for something like this.
You need some unique identifier for new users such as email, id, etc. For example, they type in emir or emir@now.com and then you query the user table to see if user with that id exits, if not let them create one.
I hope this makes sense.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 08:35 PM
Hi Emir. Thank you for your response! Actually, this is only practice exercise given by my instructor. I really cant figure out how to write a script for this one. should I use glide record or gs ?