on after Transform Map Script not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2024 12:23 AM
Hi All,
I'm importing the data to cmdb_ci table so based on class this will also get updated in alm_asset table.
Now I'm trying to update the status field of alm_asset table since it is not directly available in cmdb_ci, For this I'm writing a onafter transform script as below but which is not working/updating the status
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var status = source.u_status;
var gr = new GlideRecord("alm_asset");
gr.addQuery('serial_number', source.u_serial_number);
gr.query();
while(gr.next()) {
if (status == "Assigned To Employee" || status == "Assigned To Location" || status == "Available" || status == "Received - Awaiting Eval") {
gr.install_status = '6';
} else if (status == "In Transit - Outbound" || status == "In Transit - Returning") {
gr.install_status = '9';
} else if (status == "Damaged") {
gr.install_status = '3';
} else if (status == "Disposed" || status == "Delete") {
gr.install_status = '7';
}
else if (status == "Pending Retrieval"){
gr.install_status = '1';
}
else if (status == "Missing"){
gr.install_status = '8';
}
gr.update();
}
})(source, map, log, target);
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2024 01:57 AM
HI @Vamshi_ch123 ,
I believe the script is fine. But, why While loop, when there will be only one record which will be retrieved with the serial number.
I would advise you to add log messages for var status to actually get the values what it's actually coming.
Hope this helps.
Regards,
Najmuddin.