- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 07:39 AM - edited ‎10-06-2022 07:41 AM
Hi,
I have created a list field(BU with options a,b,c,d) in the sn_gf_goal_target table.
and another string field(Selected BU) in the sn_gf_goal table.
I want to copy the value of List from the Target table to Goal table.
Suppose Goal table has 3 Target records(1,2,3), and
1 is selected a,b
2 is selected c,d
3 is selected a,d.
Then in the selected BU all a,b,c,d will populate
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 11:03 PM
Hi,
then update as this
var a = current.u_bu.getDisplayValue();
gs.addInfoMessage(a);
var gr = new GlideRecord('sn_gf_goal');
gr.addQuery('sys_id', current.goal);
gr.query();
if (gr.next()) {
gr.u_se_bu = gr.u_se_bu + ',' + a;
gr.update();
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 10:34 PM
Hi Ankur,
before GlideRecord I missed the "new". Now Value is updating. But now problem is that it is updating whole value.
My scenario is :
Suppose Goal table has 3 Target records(1,2,3), and
1 is selected a,b
2 is selected c,d
3 is selected a,d.
Then in the selected BU all a,b,c,d will populate.
it should not override. If I change the value of 1 as only b and 3 as only d
then in selected bu b,c,d should display.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 11:03 PM
Hi,
then update as this
var a = current.u_bu.getDisplayValue();
gs.addInfoMessage(a);
var gr = new GlideRecord('sn_gf_goal');
gr.addQuery('sys_id', current.goal);
gr.query();
if (gr.next()) {
gr.u_se_bu = gr.u_se_bu + ',' + a;
gr.update();
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 11:45 PM - edited ‎10-06-2022 11:52 PM
Thanks Ankur.
Duplicate values are coming. How to omit that?
And also when I am removing BU value in Target form, Selected BU is not getting empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 11:51 PM
Hi,
get unique values
var arrayUtil = new global.ArrayUtil();
var a = current.u_bu.getDisplayValue();
gs.addInfoMessage(a);
var gr = new GlideRecord('sn_gf_goal');
gr.addQuery('sys_id', current.goal);
gr.query();
if (gr.next()) {
var arr = gr.u_se_bu.toString().split(',');
arr.push(a);
arr = arrayUtil.unique(arr);
gr.u_se_bu = arr.toString();
gr.update();
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2022 11:59 PM
Hi Ankur,
Still coming duplicate value.
Is it coming because i am selecting same value for different record?