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

Mark Stanger
Giga Sage

Configure the dictionary entry for the 'Asset tag' field and check the 'Unique' checkbox.

it gives me error. doesn't let me as there are already duplicate records there

You need to clean up the duplicates first and make all of the existing data unique.  Once you do that you can check the 'Unique' checkbox and it will prevent future duplicates.  You can use a 'before insert' business rule, but if you really need to have the data be unique you should clean it up first.

RudhraKAM
Tera Guru

open a record and right click on the asset tag and config dictionary

 

you should see a unique check box 

 

 

 

if it is not there right click 

 

add the unique and check that and save ,, 

 

it might throw an error if there are already duplicates exist