- 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 07:53 PM
Hi,
I could see both are drop-down types
You can only sync those when both have same choice values in backend
Why to have 2 fields to show data 2 times?
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 07:59 PM
Hi Ankur, for GT Pillar field, it will be read-only to non-admin so that they can't edit the column. The condition is:
1. if I choose Pillar BU - BE - Group CEO, in GT Pillar column will automatically update to GSD-BE.
2. if I choose Pillar BU - Commercial Banking, in GT Pillar column will automatically update to GBS-TC.
3. if I choose Pillar BU - Consumer Banking, in GT Pillar column will automatically update to GBS-CB.
So that I can generate the report based on the mapping required
How to achieve this? Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 08:05 PM
Hi,
in that case you can use before update BR and update the GT Pillar based on Pillar
what is the script you used and what is not working?
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:15 PM
Hi Ankur,
Here is my script in BR.
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', current.sys_id);
gr.query();
if (gr.next()) {
var pr= gr.getValue('u_pillar');
gs.log("Pillar : " + pr);
if (pr.getValue('bu_be_group_ceo')) {
gr.u_gt_pillar = be;
} else if (pr.getValue('bu_commercial_banking')){
gr.u_gt_pillar = tc;
} else if (pr.getValue('bu_consumer_banking')) {
gr.u_tco_category = cb;
}
gr.setWorkflow(false);
gr.update();
}