Change Model Restriction to Some Group Members
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2023 02:18 AM
Hello All,
I want my change request to be available only for certain Assignment groups based on my Assignment group department value. (Department value is a custom field on my groups table). If the Department value is only something XXX then for those Assignment groups only it should be visible. Therefore for other Assignment groups it should not be visible in change landing page. How to achieve using scripting in available for section in change model. Can anyone help me on this.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2023 03:18 AM
so if logged in user belongs to any group which has Department value as XXX then it should be shown?
If the above is correct then do this
var rec = new GlideRecord('sys_user_grmember');
rec.addQuery('user', user_id);
rec.addQuery('group.departmentField', 'XXX'); // give the correct field name and correct value to compare
// if the department field is reference then give sysId to compare
rec.setLimit(1);
answer = rec.hasNext();
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-31-2023 03:46 AM
@Ankur Bawiskar
It's not restricting the change model. Its not working even after giving correct field name and value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2023 04:16 AM
share your script and what analysis have you done so far?
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-31-2023 04:22 AM
@Ankur Bawiskar
I have used your same script just replaced department field with proper field name and values|
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2023 05:39 AM
u_department_label is reference field? referring which table?
are you using correct sysId to compare
did you add logs and check?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader