log error not working in onbefore transform map script in scoped app

Shravani Kantha
Tera Contributor

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

5 REPLIES 5

Omkar Kumbhar
Mega Sage
Mega Sage

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');

}

}

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

Dhruv Chandan
Giga Guru

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!

Kartik Choudha1
Tera Guru

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

Shravani Kantha
Tera Contributor

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.

 

ShravaniKantha_0-1676283865192.png

Regards,

Shravani