how to compare 2 strings to get the group name

Priya75
Tera Contributor

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.

 

 

6 REPLIES 6

@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

Tai Vu
Kilo Patron
Kilo Patron

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.

TaiVu_0-1696927826518.png

 

Let me know if it works for you.

 

Cheers,

Tai Vu