i know the group name using get() method how we can get single group in group table

mani55
Tera Contributor

i know the group name using get() method how we can get that single group in group table

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@mani55 

simply use this

var groupName = 'Your Group Name'; // Replace with your group name
var groupGR = new GlideRecord('sys_user_group');
if (groupGR.get('name', groupName)) {
    // Group found
    gs.info('Group found: ' + groupGR.name);
} else {
    // Group not found
    gs.info('Group not found');
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

6 REPLIES 6

J Siva
Tera Sage

Hi @mani55 
Could you please give more info on your requirement? It's unclear.

Ankur Bawiskar
Tera Patron
Tera Patron

@mani55 

simply use this

var groupName = 'Your Group Name'; // Replace with your group name
var groupGR = new GlideRecord('sys_user_group');
if (groupGR.get('name', groupName)) {
    // Group found
    gs.info('Group found: ' + groupGR.name);
} else {
    // Group not found
    gs.info('Group not found');
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

anukur we can use below as well or not

var grpGR = new GlideRecord('sys_user_group');
grpGR.get('name','TEM Mobile Services');
assignement_group = grpGR.sys_id+'';

Yes, you can use if you are sure about the group name.