- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2021 01:40 AM
Hi All,
I have 'string' type field on my field. This field holds the value of groups from group table.
Now I have to push these values to a different field type 'list'.
I am trying to pass these values from string field to server side. Glide record group table and get the sys id of all the groups passed and then add to list type. Is this feasible or any other approach?
Note: My main requirement is to add multiple values to assignment group field at same time instead of adding indivisually. Since that was not wroking i am first adding the groups in a new string type field.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2021 05:26 AM
try this in Before BR
(function executeRule(current, previous /*null when async*/ ) {
var groups = current.u_groups; //0f9881b02f612010501d9bacf699b67c , b6a8cd702f612010501d9bacf699b6b1
var arr = [];
var gr = new GlideRecord('sys_user_group');
gr.addQuery('nameIN'+ current.getValue("u_groups"));
gr.query();
while (gr.next()) {
arr.push(gr.getValue("sys_id"));
}
current.u_assignment_group = arr;
gs.log('test u_assignment_group ' + current.u_assignment_group);
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2021 02:07 AM
You can initialize all those values in an array and use that to update the list field.
var arr = [group0,group1,group2];
current.assignment_group=arr;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2021 04:37 AM
Hi Pranesh
I tried this way but the values are not set to the assgignment group field.
I am setting this using 'After' BR and condition is when group field changes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2021 05:02 AM
Can you share the BR script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2021 05:22 AM
(function executeRule(current, previous /*null when async*/ ) {
var groups = current.u_groups; //0f9881b02f612010501d9bacf699b67c , b6a8cd702f612010501d9bacf699b6b1
var arr = [];
var gr = new GlideRecord('sys_user_group');
gr.addQuery('nameIN'+ current.getValue("u_groups"));
gr.query();
while (gr.next()) {
arr.push(gr.getValue("sys_id") + "");
}
current.u_assignment_group = arr.join(',');
gs.log('test u_assignment_group ' + current.u_assignment_group);
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2021 05:26 AM
try this in Before BR
(function executeRule(current, previous /*null when async*/ ) {
var groups = current.u_groups; //0f9881b02f612010501d9bacf699b67c , b6a8cd702f612010501d9bacf699b6b1
var arr = [];
var gr = new GlideRecord('sys_user_group');
gr.addQuery('nameIN'+ current.getValue("u_groups"));
gr.query();
while (gr.next()) {
arr.push(gr.getValue("sys_id"));
}
current.u_assignment_group = arr;
gs.log('test u_assignment_group ' + current.u_assignment_group);
})(current, previous);