How to access target onAfter script in IntegrationHub ETL definition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi Devs,
I am having issue accessing the target in the ETL defintion in an IntegrationHub import. I am trying to update the records on the target in an onAfter script. I cannot access the target object, when I log it, the target returns undefined and null, however the target record is populated from the import set.
Create Extract Transform Load (ETL) definitions - I have also tried to stringify the target object, but I still cannot update the target. and target.update() shows that the function is not defined in the logs.
This is my current script, it is not updating the target records.
(function onAfter(source, target, importLog) {
var userGR = new GlideRecord('sys_user');
userGR.addQuery('email', source.email);
userGR.query();
if (userGR.next()) {
target.user = userGR.sys_id;
target.last_synced = new GlideDateTime();
gs.info('onAfter email=' + source.email +
' | target=' + target +
' | user =' + userGR.sys_id);
}
})(source, target, importLog);error when trying to use target.update();
com.glide.script.RhinoEcmaError: Cannot find function update in object [object Object].
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi,
The 'target' variable isn't a singular GlideRecord, it's a object containing an array of objects depending on what records you're inserting/updating. From memory, the object is a java object, and doesn't log out property. However you can use script tracer, and add break points in your script to then use the script debugger to see the value/structure of the object