onComplete transform script is not working as expected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2016 05:47 AM
Hi,
I am working on Helsinki version of Service Now.
I have a scheduled job which imports data using REST message from some URL and stores in a staging table.
Then I am using a transform map to transform this data into target table.
Here is the issue, I need to delete records from target table which have not been updated from this import.
For this I have given an onComplete() transform form script which should delete unupdated data based on some filter query. but this script is not working as expected. As my understanding it should delete the data matching to filter condition after all the data has been transformed from staging to target table.
inplace of this, this script is deleting data before transformation.
I don't know what is going wrong with this script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2016 05:54 AM
Hi Deepti,
Perhaps check the logic of your script since it may be deleting more data than what you're intending. Would you like to share more in detail your desired filter logic and your script over here?
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2016 06:00 AM
Hi Berny,
Thanks for replying,
Below is my script:
var rec = new GlideRecord('cmdb_rel_ci');
rec.addEncodedQuery('u_source=Asset Insight^sys_updated_on<javascript:gs.hoursAgo(2)');
rec.query();
if(rec.next()) {
rec.deleteRecord();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2016 07:41 AM
Hi Deepti,
Your problem may be somewhere else because on that script the most you could end up deleting is one record each time is executed.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2016 07:42 AM
That's because you're using an if instead of a while.
Thanks,
Berny
