- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2020 06:43 AM
Hello All,
Hope everyone is doing well and good!!!
I have a field called tier1 (check box:true/false filed smiliar to vip field )in the sys_user form ,Everytime i load the data of users to the user table using transform maps all the existing users whose tier1 values are true need to be made false and the loaded data of users will have the tier1 value as true.
the data will be provided every month and whenever i upload the data the old users or the users whose tier1 value is true should be stripped to false and only the data in excel users will have true .
How can i achieve this using transform maps and transform scripts
Thank you!!! in advance
Kumar
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2020 07:18 AM
Hi,
Please try with below onStart script,
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var userGr=new GlideRecord('sys_user');
userGr.addQuery('tier1',true);
while(userGr.next())
{
userGr.tier1=false;
userGr.update();
}
})(source, map, log, target);
for new user if you don't have tier1 field in source table use onBefore Script to make it true.
Please mark if that help you!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2020 06:53 AM
HI Krishna,
you can use scheduled job(runs monthly: specify date) to make all existing users tier1 value false .
for that you have to glide the user table and set all users tier1 value false.
code:
var gr=new GlideRecord("sys_user");
gr.addQuery("tier1",true);
gr.query();
while(gr.next())
{
gr.tier1 = false ;
gr.update();
}
while uploading new users keep tier1 value is true
Kindly Mark helpful and correct if it works.
Regards,
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2020 07:07 AM
Hi Harish,
Thanks for the reply!! i wanted to know one thing while uploading the data for new users where will i set the value of tier1 to true for only the loaded data of users will it be through the transform script and how, can u explain with the transform script for that part.
can this whole thing be done using a trnasform script (i.e like updating the user data to make it false and make the loaded users as tier1 true) since we do not have a defenite date for which the data will be provided
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2020 07:04 AM
Hi Harish,
Thanks for the reply!! i wanted to know one thing while uploading the data for new users where will i set the value of tier1 to true for only the loaded data of users will it be through the transform script and how, can u explain with the transform script for that part.
Thanks
Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2020 07:06 AM
can this whole thing be done using a trnasform script (i.e like updating the user data to make it false and make the loaded users as tier1 true) since we do not have a defenite date for which the data will be provided