how to compare 2 strings to get the group name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 12:40 AM
I want to match 2 strings. eg :- absc-suuportGroup and absc-suuportGroup-Approval group ,
if the string matches from the beginning till group- then i wnat to fetch the sys id of absc-suuportGroup-Approval.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 12:50 AM
@Priya75 Here is the script you can use.
var firstGroup = "absc-suuportGroup";
var secondGroup = "absc-suuportGroup-Approval group";
if(secondGroup.startsWith(firstGroup)){
gs.info('match');
var glideGroup = new GlideRecord('sys_user_group');
if(glideGroup.get('name',secondGroup)){
gs.info(glideGroup.sys_id);
}
}
else{
gs.info('no match');
}
Please mark the answer helpful and correct if it manages to address your requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 12:54 AM - edited 10-10-2023 12:59 AM
i don't have second group name, i need to glide that from table and match it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 01:09 AM - edited 10-10-2023 01:24 AM
@Priya75 Here is the updated script.
var firstGroup = "absc-suuportGroup";
var glideGroup = new GlideRecord('sys_user_group');
glideGroup.addEncodedQuery('nameSTARTSWITH'+firstGroup);
glideGroup.query();
if(glideGroup.next()){
gs.info(glideGroup.getValue('sys_id'));
}
else{
gs.info('no match found');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 01:25 AM
Hi,
So in this scenario, it matches the first group name string but what i want to match the first string, but it should end with -approval also. So it should be "absc-suuportGroup-Approval" , it should match the absc-suuportGroup but end with approval .