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

Priya Shid1
Kilo Guru

Hi ,

 

You can use onStart transform script and glide the previous user to update the tier1 to false.And for new record you can set it to true.

 

Please mark if that helps you!!

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