How to map existing field to new field ?

Nur1
Tera Contributor

Hi community,

I need to map from u_pillar to new field u_gt_pillar in sys_user table. For example, I want to map BU - BE - Group CEO from u_pillar according to its GT Pillar is GSD-BE. I need to ensure any changes in Pillar field will auto refresh/ update the "GT Pillar" field accordingly in user table. So that the information in both fields are in sync. How to achieve this ? Kindly, please help. Thanks

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Hi,

If this is one time activity then you need to run fix script/background script to map both field values.

If you want that behavior from this point onwards then you can use business rule or flow to populate another field.

You can run  below script in background script:

var grUser = new GlideRecord('sys_user');
grUser.setLimit(1000); // use setLimit if you have more records
grUser.query();
while(grUser.next()){
if(grUser.u_gt_pillar == 'BU - BE - Group CEO'){ // use value of this choice as per your configuration
grUser.u_piller = 'GSD-BE'; // use value as per your configuration.
}else if(grUser.u_gt_pillar == ''){ //same logic for other choice goes here
grUser.u_piller = '';
}else if(grUser.u_gt_pillar == ''){
grUser.u_piller = '';
}
grUser.update();
}

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

16 REPLIES 16

To Update all record you can simply use below script. No need to add any query.

If you add query then it will update records matching your query.

 

var grUser = new GlideRecord('sys_user');
grUser.query();
while(grUser.next()){
//rest of the logic here

//update last two lines like below
grUser.setWorkflow(false);
grUser.update();
}

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Nur1
Tera Contributor

Hi Anil,

All working fine as requested. Thanks a lot for your kind help.