How do you combine two asset records?

NFGDom
Mega Sage

Hello!

We're currently working on an issue where we have duplicate assets being created within alm_asset. One asset is created via discovery and the other is by our procurement user. We believed we've fixed the issue where discovery was not identifying the record created by the user and updating that. Now we have clean-up to do for the duplicates.

So far I've identified the duplicates by running this script:

gatherDupes();
function gatherDupes() {
var gr = new GlideAggregate('alm_asset'); //you can do this based on any table in cmdb
gr.addAggregate('COUNT', 'serial_number'); //based on what field
gr.groupBy('serial_number'); //grouping by field
gr.addHaving('COUNT', '>', 1);
gr.query();
while (gr.next()) {
gs.log("Numb of Duplicates: " + gr.getAggregate('COUNT', 'serial_number') + " => " + gr.serial_number);
}
}

Now our question is, what's the best way to clean these records up? Would it be via a fix-script or background script? If so what would that look like since all the fields would need to be merged from record A to record B. Or is there a better best practice in doing this? What about relationships or references for the asset record? i.e. if a user has an asset assigned to them.

Thanks in advance! 

1 ACCEPTED SOLUTION

Pratiksha Kalam
Kilo Sage

Hello,

Ref,

duplicate record in asset table

remove duplicates from asset table

 

If answer is helpful please mark correct or helpful!


Thanks,
Pratiksha

View solution in original post

4 REPLIES 4

Pratiksha Kalam
Kilo Sage

Hello,

Ref,

duplicate record in asset table

remove duplicates from asset table

 

If answer is helpful please mark correct or helpful!


Thanks,
Pratiksha

Thank you! This helped!

You are Welcome!

Harshal Gawali
Giga Guru

Hello,

You need to write an identification rule to avoid duplication of record in asset table.

Best practise is to write script in a fix script because fix script changes are capture in an update set.

But when you are deleting record via background script so these changes are not capture in update set.

It is difficult to track changes when you are deleting record via background script.

so my suggestion is you need to write fix script to delete duplicate record.

 

Regards,

Harshal