- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
02-13-2025 05:55 PM
Following up on my previous question, I would appreciate your guidance.
I am currently creating a variable that refers only to users who belong to the selected group in the form.
In order to have multiple users selected, I have set the group and user variables in a multi-line variable set.
Group variables are set outside the variable set,
Is it possible for the user's variable in the variable set to get the value of the group selected in the group's variable?
The current user variable settings are as follows
■User Variables
Type: reference
Reference table: sys_user
Use reference modifier: Advanced
Reference modifier (script)
group_field: reference variable for sys_user_group
javascript:
var query;
var value = current.variables.group_field;
var grmem = new GlideRecord('sys_user_grmember');
grmem.addQuery('group', value);
grmem.query();
var usrIDs = [];
while (grmem.next()) {
usrIDs.push(grmem.user.sys_id.toString());
}
query = 'sys_idIN' + usrIDs.join(',');
query;
解決済! 解決策の投稿を見る。
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
02-13-2025 06:31 PM
Hi, I think I understand what you're attempting to accomplish. Instead of creating a script for this, have you considered utilizing an advanced qualifier field value? I'll attach examples below. The first thing you'll need to do is create a business rule utilizing this code, replacing 'groupField' with the name of your group reference field.
function groupSelect(groupField) {
var userGroup = current.getValue(groupField);
if (gs.nil(userGroup)) {
return "active=true^EQ";
}
var member = new GlideRecord("sys_user_grmember");
member.addQuery("group", userGroup);
member.query();
var list = [];
while (member.next()) {
list.push(member.getValue("user"));
}
return "sys_idIN" + list.toString();
}
Next, find the user field that you'd like to adjust based on the group. You'll right click its label, then click "Configure Dictionary".
Enter the following script in the 'Reference qual' field:
javascript:groupSelect('groupField')
Again, remember to replace 'groupField' with the name of the group reference field you're utilizing. I hope this is helpful for you! Please let me know if you'd like any adjustments, or are trying to accomplish something different.
If I've at all helped, please return the favor by clicking the thumb next to my post. Thanks!
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
02-13-2025 06:31 PM
Hi, I think I understand what you're attempting to accomplish. Instead of creating a script for this, have you considered utilizing an advanced qualifier field value? I'll attach examples below. The first thing you'll need to do is create a business rule utilizing this code, replacing 'groupField' with the name of your group reference field.
function groupSelect(groupField) {
var userGroup = current.getValue(groupField);
if (gs.nil(userGroup)) {
return "active=true^EQ";
}
var member = new GlideRecord("sys_user_grmember");
member.addQuery("group", userGroup);
member.query();
var list = [];
while (member.next()) {
list.push(member.getValue("user"));
}
return "sys_idIN" + list.toString();
}
Next, find the user field that you'd like to adjust based on the group. You'll right click its label, then click "Configure Dictionary".
Enter the following script in the 'Reference qual' field:
javascript:groupSelect('groupField')
Again, remember to replace 'groupField' with the name of the group reference field you're utilizing. I hope this is helpful for you! Please let me know if you'd like any adjustments, or are trying to accomplish something different.
If I've at all helped, please return the favor by clicking the thumb next to my post. Thanks!
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
02-13-2025 09:08 PM
yes if the variable set is single line then you should still be able to access it
so your ref qualifier should work fine
what's the issue?
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