- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 07:49 PM
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
Solved! Go to Solution.
- Labels:
-
Project Portfolio Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 08:13 PM
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
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 08:30 PM
Hi,
GlideRecord is not required as BR runs on user table and fields are on user table
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 08:13 PM
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
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 08:17 PM
Hi Anil,
Can I use this script in before Business Rules ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 08:20 PM
To use it before BR you need to change it like below:
if(current.u_gt_pillar == 'BU - BE - Group CEO'){ // use value of this choice as per your configuration
current.u_piller = 'GSD-BE'; // use value as per your configuration.
}else if(current.u_gt_pillar == ''){ //same logic for other choice goes here
current.u_piller = '';
}else if(current.u_gt_pillar == ''){
current.u_piller = '';
}
No need to use GlideRecord query use current to update value.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 09:26 PM
Hi Anil,
I've used your script, but the GT Pillar column are not updated according to selected Pillar.
1. First, I select BU - BE - Group CEO from Pillar column, then click save, it updated correctly in GT Pillar column which shows GSD-BE.
2. I change Pillar to BU - Commercial Banking in Pillar column, then click save, the value in GT Pillar column still showing GSD-BE instead of GBS-TC.
Here is my script:
if(current.u_pillar == 'bu_be_group_ceo'){
current.u_gt_pillar = 11;
}else if(current.u_pillar == 'bu_commercial_banking'){
current.u_gt_pillarr = 12;
}else if(current.u_pillar == 'bu_consumer_banking'){
current.u_gt_pillarr = 13;
}
Or is there any error in my conditions ?