- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 11:46 AM
We have an integration with our HR systems that sends user data to our user table and triggers various on boarding activities. When the data hits our system it goes directly into an import set table, imp_user. From there it transforms and populates the sys_user table. The problem that we're having is that the imp_user table only holds the data for a few days before it gets purged. I need that data as a permanent record of what we received. So, I've created a new table to house this data, u_imp_user_history. Now the transform runs for this table and sends it to my new table. This works great, but I can't get the correct value to come over for the sys_import_state field. It always sends over Pending.
To address this, I've created a business rule. This rule runs on the imp_user table, after insert. The condition is if State changes from Pending, run the following script:
(function executeRule(current, previous /*null when async*/) {
var rec = new GlideRecord('u_import_user_history');
rec.addQuery('sys_id', current.sys_id);
rec.query();
while (rec.next()) {
rec.u_status = current.sys_import_state;
gs.log("STATUS: " + rec.u_status);
rec.update();
}
})(current, previous);
I can't seem to get this to update the status value on the new table. Any ideas?
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 12:34 PM
_queryIsets : function() {
var gr = new GlideRecord('sys_import_set');
gr.setLimit(this.isetsChunk);
if (this.table)
gr.addQuery('table_name', this.table);
if (this.daysAgo > 0)
gr.addEncodedQuery('sys_created_onRELATIVELE@dayofweek@ago@' + this.daysAgo);
/*** Put your Import set table name**/
gr.addQuery('table_name','!=','YOUR TABLE NAME');
/******************************/
gr.query();
var isets = new Array();
while (gr.next()) {
this._log('Cleaning import set ' + gr.number);
isets.push(gr.sys_id + '');
}
return isets;
}
Hope this Helps,
Aman Gurram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2019 12:34 PM
_queryIsets : function() {
var gr = new GlideRecord('sys_import_set');
gr.setLimit(this.isetsChunk);
if (this.table)
gr.addQuery('table_name', this.table);
if (this.daysAgo > 0)
gr.addEncodedQuery('sys_created_onRELATIVELE@dayofweek@ago@' + this.daysAgo);
/*** Put your Import set table name**/
gr.addQuery('table_name','!=','YOUR TABLE NAME');
/******************************/
gr.query();
var isets = new Array();
while (gr.next()) {
this._log('Cleaning import set ' + gr.number);
isets.push(gr.sys_id + '');
}
return isets;
}
Hope this Helps,
Aman Gurram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2019 12:05 PM
Thanks Aman. I'll give this a try and let you know how it works out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2019 10:41 AM
Thanks Aman!