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

Hi Shravani,

 

I am attaching few of the links for your reference that will help you to understand where these log.info, log.warn and log.error messages generally display.

 

https://www.servicenow.com/community/now-platform-forum/list-of-all-error-code-in-import-set-row-err...

 

https://www.servicenow.com/community/developer-forum/onbefore-transform-script-s-log-info-str-not-wo...

 

As per above links, log.error, info, warn messages display under Message field with the level as 'warning', 'information' or 'error' in Import Log table.

 

And OOB Field Map Transform errors like wrong Reference Field value given or in case of incorrect choice field value. Those errors gets created into sys_import_set_error table and the same will be shown in 'Error' field. This 'Error' field is the reference field which refers to 'sys_import_set_error' table only.

 

I have seen OOB errors are visible in 'error' field.

 

KartikChoudha1_0-1676292317978.png

 

There could be workaround if you want to show custom messages in import set record but that will be appeared in 'comment' field appended by OOB transform script message.

 

you can write below two statements in transform scripts.

 

ignore = true;
 source.sys_import_state_comment = ''xyx';

 

It will be shown like this in comment field.

KartikChoudha1_2-1676292544604.png

 

Kindly correct me if anything is not correct.

 

Hope this helps!

Regards,

Kartik Choudhary