Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Need help with Fix script

Chandrika4
Tera Contributor

Hi All, 

I have the below requirements for certain child classes of DB Instance:

For the existing duplicates, check if there are any records having same name, version and related child, then retire the older records if not already.

 Also copy the field values of these 3 fields from the latest one in the old records to the latest record if empty:

Support Group, Owned By and Tags

 

Please help on the above, Sharing a Fix script I have written.

2 REPLIES 2

Rafael Batistot
Kilo Patron

Hi @Chandrika4 

 

May try replace

 

if (!latestCI || oldCIIds.length === 0) {
continue;
}

 

to 

 

var shouldContinue = (!latestCI || oldCIIds.length === 0) ? true : false;
var finalContinue = shouldContinue ? continue : null;

finalContinue;

 

If this response was helpful, please mark it as Helpful and, if applicable, as Correct.
This helps other users find accurate and useful information more easily

l457
Kilo Patron

I'd suggest using de-duplication tasks which you can create manually with CMDBDuplicateTaskUtils  

 

As to your script, where does it fail? Only thing that sticks out is that tags do not work like normal fields, you'd have to update the corresponding entry in the [label_entry] table