- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2019 05:56 AM
I'm fairly new to Servicenow, been on the platform as an admin for about 4 months, and I am trying to update 32 groups with a fix script vs manually opening the records and updating the group type. Here is what I have:
var grp = new GlideRecord('sys_user_group');
var grname='';
grp.addQuery('sys_id');
grp.query();
while(grp.next()){
grname=grp.name;
}
if(grname.includes("Director")){
grp.type = grp.type + ",1cb8ab9bff500200158bffffffffff62";
}
I'm missing something, I'm just not sure what.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2019 06:09 AM
Hi Matt,
See my comments below:
var grp = new GlideRecord('sys_user_group');
grp.addQuery('name', 'CONTAINS', 'Director'); // this is the right way to build query
grp.query();
while(grp.next()){
grp.type = grp.type + ",1cb8ab9bff500200158bffffffffff62";
grp.update();
}
Please test the query by printing the group names before updating the record.
-Anurag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2019 06:09 AM
Hi Matt,
So you want to update the group which has name containing Director and update the group type.
Do you want to include one more group type to the existing one?
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2019 06:09 AM
Hi Matt,
See my comments below:
var grp = new GlideRecord('sys_user_group');
grp.addQuery('name', 'CONTAINS', 'Director'); // this is the right way to build query
grp.query();
while(grp.next()){
grp.type = grp.type + ",1cb8ab9bff500200158bffffffffff62";
grp.update();
}
Please test the query by printing the group names before updating the record.
-Anurag