Transform map script to update records in user table and re-update the same with the loaded data.

krishna111
Tera Contributor

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

 

 

1 ACCEPTED SOLUTION

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!!

View solution in original post

6 REPLIES 6

Harish Vaibhare
Kilo Guru

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

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 

krishna111
Tera Contributor

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

krishna111
Tera Contributor

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