How to see import log when a transform map script run?

Suyash Joshi
Tera Contributor

Hi all,

I am facing an issue while  running a transform map script (on complete) I want to transform a large excel file in which I want to count all the record via number with each record respectively with their sys_id.

 

Code ://

(function runTransformScript(source, map, log, target /* GlideRecord */) {
// Your transformation logic here

// After your transformation logic is complete and you want to insert the record
if (target) {
var newRecord = new GlideRecord('your_target_table');

// Set the fields on the new record as needed
newRecord.field1 = target.field1;
newRecord.field2 = target.field2;
// ... (set other fields)

// Insert the new record
var newSysId = newRecord.insert();

if (newSysId) {
log.info('New record inserted with sys_id: ' + newSysId);
// You can use newSysId in subsequent processing if needed
} else {
log.error('Failed to insert new record');
}
}
})(source, map, log, target);

 

I still unable to get response on Import logs!!

Everything consider as a help.

Regards,

Suyash

1 ACCEPTED SOLUTION

You can add below line in transform script to add the comment in import row

source.sys_import_state_comment = "Row Transform succcesfull" ; //Comment in Import Row

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

View solution in original post

7 REPLIES 7

Voona Rohila
Kilo Patron
Kilo Patron

HI @Suyash Joshi 

try gs.info() or gs.error() for logging.

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Hello @Voona Rohila 

The following requirement has been changed actually now I want count of total record  in which I run a code below :-

var gr = new GlideRecord('table_name');

gr.addQuery('sys_import_set',source.sys_import_set);

gr.query();

var count = gr.getRowCount();

gs.log('The record are:'+count);

 

I have two doubts can you help?

1. Can I see any update record on import log with my info? (Because I'm only see record via error or information).

2. I want to see record which is count in import log when the transform script run on (onComplete only).

 

Regards,

Suyash

Hi @Suyash Joshi 

Your requirement is not clear to me, can you explain in detail.


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

@Voona Rohila  Mam,

Firstly we have an large excel file having n number of record. We have to count our record by transform map script, which I completed the count with onComplete script. I mention my code above.

 

There is two requirement :- 

1. Import log detail, when we complete the script successfully no import log generated. Is import log only generated error or information messages(like table cleanup message, import set tables cleanup) only?

2. Where I can see the script execution except system logs! 

 

(Any documentation will also help regarding 1 question)

 

Thanks and Regards,

Suyash