The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Excel import of assets creating new assets and taking long to transform.

jjones4773
Tera Guru

I'm trying to migrate from a manual asset input over to SCCM driven import.  Assets are currently in our dev environment, but when I transform the additional fields from the prod environment, it will update some, but others will create a new asset.  And it seems to fun forever.  Any assistance would be helpful.

 

Attached is the export file and below is the script for the transform map.

 

(function transformRow(source, target, map, log, isUpdate) {

    // Add your code here

    var ImportTable = new GlideRecord('u_assettagassignedtoupdate');
ImportTable.query();

while (ImportTable.next()) {
    var serialNumber = ImportTable.u_serial_number; // Assuming 'serial_number' is the field name in import_table
    var asset = new GlideRecord('alm_hardware'); // Replace with the appropriate asset table
    if (asset.get('serial_number', serialNumber)) {
        // Update fields on the asset record
        asset.asset_tag = ImportTable.u_asset_tag
        asset.location = ImportTable.u_location;
        asset.assigned_to = ImportTable.u_assigned_to;
        asset.department = ImportTable.u_department;
        asset.comments = ImportTable.u_comments;
        asset.u_location_type = ImportTable.u_location_type;
        asset.u_dock_serial_number = ImportTable.u_dock_serial_number;

        // Save the changes
        asset.update();
    } else {
        // Handle cases where the serial number does not match any asset
        gs.info('No matching asset found for serial number: ' + serialNumber);
    }
}

})(source, target, map, log, action==="update");
 
 
I also tried to do just field mapping with a coelesce on Serial Number and that didn't work either. Created additional assets.
 
jjones4773_0-1718915920263.png

With the script, the Field Maps are blank.

 

Any assistance is appreciated.

 

Jason

1 REPLY 1

A-Sprague
ServiceNow Employee
ServiceNow Employee

I could not think of a quick fix based on the information provided, hopefully this playbook will help.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1002123