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 01:35 AM
@Priya75 Since you do not have the second group name, how would you insure that the group search ends with -approval. If it is a static keyword, then it can be searched but if the name ends with a dynamic keyword then it would be difficult.
Please confirm if you need to search for static group names absc-suuportGroup and absc-suuportGroup-Approval group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 01:50 AM
Hi @Priya75
Give below script a try.
var grGroup = new GlideRecord('sys_user_group');
grGroup.addQuery('name', 'STARTSWITH', 'absc-suuportGroup');
grGroup.addQuery('name', 'ENDSWITH', '-Approval');
grGroup.addActiveQuery();
grGroup.query();
while(grGroup.next()){
gs.info(grGroup.getUniqueValue());
}
And enjoy the result.
Let me know if it works for you.
Cheers,
Tai Vu