log error not working in onbefore transform map script in scoped app
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2023 01:20 AM
Hi,
Trying to log CI name which is not found in error during transform map(onbefore script) and log is not working in scoped app. Record is getting ignored as expected, only error message was not working. Tried with log.info as its scope but no luck.
var ci = new GlideRecord('cmdb_ci');
ci.addQuery('sys_class_name', source.u_asset_table);
ci.addQuery('name', source.u_app_service_name);
ci.query();
if (ci.next()) {
target.asset_table = ci.sys_class_name;
target.asset_name = ci.sys_id;
} else {
log.error("Asset name not found:" +source.u_app_service_name);
ignore = true;
}
Regards,
Shravani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2023 01:38 AM
Hello @Shravani Kantha ,
I think you are missing the if condition hence it is executed else loop and priting the error.
Can you try adding what if condition
if(ci.next())
{
if('your condition')
{
}
else
{
gs.info('print he log');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2023 01:43 AM
Hi @Shravani Kantha ,
Could you try the below ?
var ci = new GlideRecord('cmdb_ci');
ci.addQuery('sys_class_name', source.u_asset_table);
ci.addQuery('name', source.u_app_service_name);
ci.query();
if (ci.next()) {
// Check if the Asset Found log shows up
gs.info("Asset name found:" +source.u_app_service_name);
target.asset_table = ci.sys_class_name;
target.asset_name = ci.sys_id;
} else {
// Check if the Asset NOT Found log shows up
gs.info("Asset name not found:" +source.u_app_service_name);
ignore = true;
}
Hope this helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2023 02:06 AM
Hi Shravani,
Could you tell us where you are seeing the message of Record is getting 'ignored' or not. And where you are trying to find this log.error message.
Could you share the screenshots with us. It will give more clarity and better to provide a precise solution.
Regards,
Kartik Choudhary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2023 02:27 AM
Hi Karthik,
I'm checking in the "comment" column of import set row that "Row transform ignored by onbefore script". Please find attached screenshot and wanted to display error message Asset not found on "error" column.
Regards,
Shravani