- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2016 11:53 AM
Is there a way to prevent duplicate asset tags and serial numbers in the Asset Management module?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2016 06:13 AM
The following business rule will throw an error message "Serial number or asset tag already exists" to the user if tries to insert duplicate serial number or asset tag and stops the insert. I have tested this and it should work for you. Make sure you only run this Business rule before insert only.
var grDupCheck = new GlideRecord('alm_asset');
grDupCheck.addQuery('serial_number', current.serial_number).addOrCondition('asset_tag',current.asset_tag);
grDupCheck.query();
if (grDupCheck.next()) {
gs.addErrorMessage("Serial number or asset tag already exists");
current.setAbortAction(true);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2016 11:57 AM
Write a Before Insert Business rule. Add this script into the business rule
var grDupCheck = new GlideRecord('alm_asset');
grDupCheck.addQuery('serial_number', current.serial_number).addOrCondition('asset_tag',current.asset_tag);
grDupCheck.query();
if (grDupCheck.next()) {
current.setAbortAction(true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2016 12:16 PM
Thank you so much!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2016 06:05 AM
g_form methods are not available on server side. Since Business Rules are server side, you cannot use those methods, they are only available on client scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2016 05:56 AM
I tried adding the line as shown, but when I do that, it will still submit the record and not abort it. I don't get a message either.