- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 02:24 AM
As Asset Manager we can't create 2 assets with the same Serial number and Manufacturer.
Serial Number and manufacturer should be unique Key to prevent any duplicate data.
Solved! Go to Solution.
- Labels:
-
Enterprise Asset Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 02:32 AM
hello
you can create a Business rule which runs before insert of the record and check for the records with same serial number or manufacturer .If a record is found then abort the insertion using below script
Make sure you replace correct serial number and manufacturer field names as per your instance dictionary configuration
var gr= new GlideRecord(current.getTableName());
gr.addQuery('serial_number',current.serial_number); // replace serial number field name
gr.addQuery('manufaturer',current.manufaturer); // replace manufacturer field name
gr.query();
if(gr.next())
{
gs.addErrorMessage('There is a already a record created with same serial number and manufacturer')
current.setAbortAction(true)
}
Hope this helps
Mark this answer correct if this helps you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 02:32 AM
Hi Deo,
Please refer to this link it has two solutions check them both. use manufacturer serial number field instead of Asset tag in the script if you go with scripting option.
How to prevent having duplicate record in asset table
Mark Correct and Helpful if it helps.
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 05:21 AM
Hi Yousaf.
i have a follow up question. What if the Serial Number and Manufacturer have different table? what would be a possible script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 02:32 AM
hello
you can create a Business rule which runs before insert of the record and check for the records with same serial number or manufacturer .If a record is found then abort the insertion using below script
Make sure you replace correct serial number and manufacturer field names as per your instance dictionary configuration
var gr= new GlideRecord(current.getTableName());
gr.addQuery('serial_number',current.serial_number); // replace serial number field name
gr.addQuery('manufaturer',current.manufaturer); // replace manufacturer field name
gr.query();
if(gr.next())
{
gs.addErrorMessage('There is a already a record created with same serial number and manufacturer')
current.setAbortAction(true)
}
Hope this helps
Mark this answer correct if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2024 02:31 AM
Hi I wrote the same but it still insert the duplicate recods
Can you please check and let me know i have made mistake.
Regards