
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2018 10:57 AM
I have a scheduled data import, using a transform map, to import our users no a daily basis. One of the included fields is 'Enabled' (source) to update the 'Active' (target) field in ServiceNow.
The need is to have a script that looks for a handful of users and changes the Enabled or Active value for them, but only them. I'm a beginner when it comes to programming and have found that this could be done with a onBefore script or maybe a source script.
Latest test is with an onBefore which is allowing the transform to run, but the value is not changing.
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if(source.login == 'nhesgz');
target.active = false;
})(source, map, log, target);
Looking for the best way to do this. Any and all suggestions are welcome.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2018 09:39 AM
okay, so when we run the script in transform map it run for each row and it will check if source.u_login matches and then it will update at run time.
onComplete() will run once when all the transformations are done for all the records (even after for the user which we wanted to set as inactive) and then it will make those users inactive.
I believe using transform map is better option since you will be checking the u_login user at run time for each row transform, and would taking action right away, instead of using onComplete() with GlideRecord query which will try to glide the sys_user table everytime for every specific records.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2018 07:00 AM
I did a quick testing with the above script and was able to make the user inactive, that's strange how users became locked out? are the same user also there in your loaded file?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2018 07:22 AM
I'm not sure either. Just verified that all the users were in the source csv.
I disabled the following BRs
- Lock Out Inactive Users
- Lock Out User
When I ran the transform again no users were locked out, but the users were all active as well. Starting to get really confused 🙂
Thoughts? When you did your test you rant is as a transform script, onStart?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2018 07:29 AM
yes, I ran as transform script, onStart() but was not having my test users (who i want to set inactive) in excel sheet.
Can you remove those user from CSV and try, so atleast we will know if there are getting overridden after running them in onStart() transform script.
What else are you doing in transform map ?
This is what I tried.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2018 07:40 AM
Nothing else really. This is the only script I'm trying to run. On the field maps I have one field, login, set to coalesce and another field choice action set to ignore. This is a manager field which lists the users manager by login and it was creating users with bland logins.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2018 08:05 AM
you mean to say these refers to user's managers? and you want to set the user's inactive who has manager any of them as mentioned below ?
nhesgz,teccmm,jpfdjg,CCSRLB,tecrlc,mhhsgx,nrslkz,teckll,teckxb,tecldl,tecdlc