- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
04-06-2025 05:41 PM
ご教示いただけますと幸いです。
参照フィールドでグループを選択すると、そのグループに紐づいているロールをリストコレクタフィールドで選択できるようにする方法はありますでしょうか。
また、リストコレクタフィールドでロールを選択すると、日付で表示されてしまうためロール名で表示したいのですが、
ロールテーブル側の表示設定ではなく、カタログUIポリシーやカタログクライアントスクリプト等で実装したいと考えております。(ロールテーブルがOOTBのため。)
-------------
We would appreciate it if you could enlighten us.
Is there a way to select a group in the reference field so that the roles associated with that group can be selected in the list collector field?
Also, when I select a role in the list collector field, it is displayed by date and I would like to display it by role name,
We would like to implement this in a catalog UI policy, catalog client script, etc., rather than in the display settings on the role table side.
解決済! 解決策の投稿を見る。
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
04-06-2025 08:20 PM
so you will select group as reference variable and then show roles associated with that group in list collector
then do this
1) list collector variable referring to sys_user_role
2) advance ref qualifier as this in that variable
javascript:
var arr = [];
var gr = new GlideRecord("sys_group_has_role");
gr.addQuery("group", current.variables.groupVariableName);
gr.query();
while (gr.next()) {
arr.push(gr.getValue('role'));
}
return 'sys_idIN' + arr.toString();
3) also in the list collector variable add this in attributes so that Role Name, Role Created on shows when user types in
Also remember to use ref_qual_elements=groupVariableName so that ref qualifier works fine.
ref_auto_completer=AJAXTableCompleter,ref_ac_columns=sys_created_on,ref_ac_columns_search=true,ref_ac_order_by=name,ref_qual_elements=groupVariableName
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
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
04-13-2025 11:44 PM
Sorry for the delay in replying. Thank you also for your instruction on how to respond.
I understood the following as you presented.
The role name should be displayed when selecting by referring to sys_user_role.
Create an object (gr), and in sys_group_has_role, acquire the role associated with the group acquired by crrent.variables.
The acquired values are returned to the filter by array processing.
When I actually tried to set up the filter, the filter for sys_user_role was not functioning properly.
Is it because the value obtained in “current.variables.groupVariableName” is sys_id?
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
04-13-2025 11:50 PM
1st variable is referring to group table (sys_user_group)
2nd variable is referring to sys_user_role either as reference or list collector type
when you do current.variables.groupVariable you will get sysId as it's a reference variable pointing to group table
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
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
04-15-2025 04:56 PM
Thank you very much.
I have set up the script you provided and was able to display only the roles associated with the selected group by role name.
The final result is as follows.
javascript:
var query;
var gr = new GlideRecord('sys_group_has_role');
gr.addQuery('group',current.variables.groupVariableName);
gr.query();
var arr = [];
while (gr.next()) {
arr.push(gr.getValue('role'));
}
query = 'sys_idIN' + arr.join(",");
query;