Is it possible to access scratchpad in transform scripts??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2019 11:02 PM
Is it possible to access scratchpad in transform scripts??
I have a requirement, where in I need to compare target table records with the input records and mark the unwanted records in target table as inactive
Please recommend.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2019 09:51 PM
Hi asoni,
go through below link.it may help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2019 05:36 PM
I will elaborate on my query.
I am inserting records to import set via Ansible Scripts. I have a use case in which I am inserting 2 records to the import set -> Record 1 and Record 2.
The target has say 4 records at the moment, (Record 1, Record 2, Record 3 and Record 4). So i want to take care of extra records in the target now.
However, I don't want to delete it rather mark it as inactive. I want to minimise hits to the database to achieve this to optimise performance as well. I hope my way of explaining is not confusing.
Please advise
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2019 06:33 PM
You can use On start transform script to check the target table for Record3 and Record4 and inactivate them.
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
gs.log("Log 1 "+source.getRowCount());//number of rows you have in the staging table
gs.log("Log 2 "+source.getLocation());//-1. The first row has not been read yet
/*
Write Logic to check for Record 3 and Record 4 by reading the target table and set required rows to inactive
while(source.next()){
var xyzGr = new GlideRecord('targetTableName');
xyzGr.addQuery('targetColumn','!=',source.getValue('compareColumn'));//Write your own condtion
xyzGr.query();
if(xyzGr.next()){
......
.....// Write logic to inactivate the record
......
}
}
*/
source.setLocation(-1);//***Important
})(source, map, log, target);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2019 09:03 PM
Thanks ARG.
I am not sure how these events should work, but when I run using onStart event and I try to insert 3 records via ansible, I see it making 3 entries in the logs and it states that row count is 1
just executing below lines of code onStart event:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
gs.log('row count: '+ source.getRowCount() + 'and row value : ' + source.getValue('u_question_text'));
})(source, map, log, target);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2019 08:25 AM
I can see that your question has been answered in another thread. Please close this thread by marking this answer as correct. So that this can be moved to the answered category.