How to prevent having duplicate record in asset table

sonita
Giga Guru

on the asset table, we want to prevent having duplicate entries for 'Asset tag'. How to achieve this?

 

 

find_real_file.png

1 ACCEPTED SOLUTION

In that case create a before BR on Insert Checked.


(function executeRule(current, previous /*null when async*/) {
var record = new GlideRecord('alm_asset');
record.addQuery('asset_tag', current.asset_tag);
record.query();
if (record.next()) {
gs.addErrorMessage("Asset tag already exists");
current.setAbortAction(true);
}
})(current, previous);


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

View solution in original post

9 REPLIES 9

Yeah it gave me error ! and i still can save duplicates!!

Actually it doesn't let me make it unique

 

In that case create a before BR on Insert Checked.


(function executeRule(current, previous /*null when async*/) {
var record = new GlideRecord('alm_asset');
record.addQuery('asset_tag', current.asset_tag);
record.query();
if (record.next()) {
gs.addErrorMessage("Asset tag already exists");
current.setAbortAction(true);
}
})(current, previous);


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Please mark my response as correct and close this thread if it answers your question. This helps in removing this thread from unanswered list and helps community.

 

-Thanks

Prateek kumar


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

you need to delete the existing duplicates and then check unique ,, then you wont have issues ,,, on the asset tag right click and group by asset tag ,, and delete the duplicates , this will fix the issue