Transform script log update
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2017 12:08 PM
Hi,
I need help with the transform script logs. Currently I am updating a bulk of assets and I need to put in logs to check.
I need logs to check which assets have been updated and which assets have not been updated in the transform.
Any suggestions are welcome.
ty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2017 05:21 AM
Hi Roger,
Yes, that is right. I guess you should be able make the log conditional based on insert/update. ServiceNow Wiki suggests action should say insert/update . I haven't tried this option before, may be you can try if 'action' serves your purpose.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2017 05:35 AM
Hi Karthik,
I didn't quite get that. Can you help me provide a script for the same, that would be helpful
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2017 01:05 PM
Hi Roger,
You can add the script under the transformation map itself (check the run script check box),
Here is the sample script I created to log insert/update, you can tweak that to your need. I think its better to make use of the transformation specific logging, instead of the generic logs.
(function transformRow(source, target, map, log, isUpdate) {
if(action == "insert"){
// writes to the generic log
gs.log('target row inserted' + target.u_number);
// writes to the log with the source details (easier to find)
log.info('target row inserted123'+ target.u_name);
}
else if(action == "update"){
// writes to the generic log
gs.log('target row updated' + target.u_number);
// writes to the log with the source details (easier to find)
log.info('target row updated456'+ target.u_name);
}
})(source, target, map, log, action==="update");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2017 09:22 AM
Hi Karthik,
Thanks for the help. But the logs are updating for all the assets even for the assets that have not been updated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2018 05:02 AM
Hi rog and @karthik do you guys have an update on this? I am also receiving "update" value on the action variable even if the there is no record to update and records are non-existent on the target table. Kindly help...