- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2021 02:08 AM
Hi, I am looking for a script which inserts or updates the row in a specific table. the update criteria is combination of few column values. if this combination don't have the existing unique value in that specific table, insert the row. This script has to run 'OnAfter' on a particular transform map. any leads on this is appreciated. thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2021 02:16 AM
yes
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var a = source.u_A;
var b = source.u_B;
var c = a + ' ' + b;
var gr = new GlideRecord('table_in_which_you_to_compare');
gr.addQuery('field_name',c);
gr.query();
if(gr.next())
{
log.info('Record already exist no need for creation');
}
else{
target.field_name = c;
target.update();
}
})(source, map, log, target);
I hope this examples gives you some reference to workout your script
Mark my ANSWER as CORRECT and HELPFUL if it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2021 05:02 AM
HI,
the above script works well with the non-referenced fields. however, I found that some fields in my case are referenced and I have the display names but not the sys_ids. what changes we need in that case? thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2021 08:39 AM