- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2017 01:58 PM
I need help with the below use case:
I have to cleanup user records, there are duplicates but no general uniqiue identifier except the full name
I have tried a number of onbefore transforms and cannot get the active record to be updated
It ignores the inactive record fine, but it does not continue to find the active record and update that;
So I have a user
Full name: James Brown
Multiple user_ids
Multiple email addresses (not always)
If I add this to the OnBefore Script
// if(!target.active){
// ignore = true;
// }
It finds the first record and if its inactive it does ignore it, however I need it to find all instances of this record and update the active one.
I tried this to see if I can lookup the users full name and if it finds the user inactive ignore it, if it finds it active update it.
Still not working.
Unfortunately the data in the sys_user table has duplicates that I am struggling with getting to update the correct record.
Since there are 90+k users (both active and inactive) I cannot easily clean this up until I have been able to update the active record.
I have a field that I am setting a value on after the record is updated that will allow me to cleanup all records that do not have this field value set, but in the meantime, I need help getting the active record updated.
var gr = new GlideRecord('sys_user');
gr.addQuery('name='+source.u_full_name.toString());
gr.query();
while(gr.next()){
if(!gr.addActiveQuery()){
ignore=true;
}
else{
target = gr;
}
}
// if(!target.active){
// ignore = true;
// }
Thank you
Tricia
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2017 04:34 AM
One more option would be .. to include active in the transform map and coalesce on it, but this needs the source data to have active field on it and it should be set to true, this will ensure that only active records are picked up and updated and rest of the ones are ignored. I just tried and it worked. I have updated the country code for a user record which was United kindom earlier to Brazil.. Below are screenshots
Import spreadsheet
Transform Map
Before Data load screenshot
After Data load and transform -screenshot
Hope this helps !
Thanks
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2017 06:18 AM
Thank you Anil,
It must have been a long day as everything I was trying did not work.
However, with fresh eyes, adding the coalece to the name and active seemed to have worked.
I need to continue testing but I think it is working.
Thank you very much!
Tricia
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2017 06:48 AM
Dear Patricia,
Thanks, please let me know if you are having any further queries
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2017 04:59 PM
Hi Anil,
I ran into a slightly different issue with the same transform.
So I have coalesce set on active and my file has active = true (so it only updates the active record)
I am also coalecing on the guid field that is in the file and a U_oim_guid field on the user table.
I have an on before script running to ignore records if they are not active.
if(!target.active){
ignore=true
}
If this is not running it still updates the user if it is inactive so I need to keep this set.
The problem I am having now is that if the user doesn't exist at all in the sys_user table, it is ignoring that as well and not creating a new record.
I think it is because of the onbefore (its not finding the user so it is treating it as inactive and then ignoring it)
How can I have it still ignore inactive accounts but if the account is not there create it?
Thank you
Tricia
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 04:48 AM
Dear Tricia,
can we make the onBefore script a little more robust, by adding the guid to it, so it would look like below.
if(!target.active && source.guid == target.U_oim_guid) {
ignore = true;
}
Thanks
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 06:52 AM
Thank you Anil!!
That worked.
Tricia