How i use START WITH condition in business rule script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2017 02:44 AM
How i use START WITH condition in business rule script
I have idea how to use contains but i am looking for how to use "Start with"
i am working with business rule ( i want to check if caller is from group where group name start with SERVICEDESK so assignment group show that group)
var relationuser= new GlideRecord('sys_user_grmember');
relationuser.addQuery('user',current.caller_id.toString()); //checking user from sys_user_grmember with caller
relationuser.addQuery('group','STARTSWITH','servicedesk');
relationuser.query();
while(relationuser.next())
{
var gname=relationuser.group.getDisplayValue(); //convert sys_id to readable text
if(gname.search('ServiceDesk') > -1 || gname.search('Service Desk') > -1) //contain group name contain service desk
{
current.assignment_group=relationuser.group;
current.u_servicedesk_relevant=true;
current.u_first_call_resolution=true;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2017 02:52 AM
Try like below encoded query string
nameSTARTSWITHabs
I place of name use element name of the field and and in place of abs use your starting search text.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2017 02:58 AM
In the condition macro, you can use the filter "the field" ,start with ,<type the string>. all provided the field is string..
in the advanced script , using gliderecord query you can use something similar to gr.addQuery('field','STARTSWITH', '<string>');
refer Using GlideRecord to Query Tables - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2017 07:42 AM
Hi Pradeep,
If my understanding is correct, group will be a reference field in sys_user_grmember table, so you have to check the condition similar as group.name instead of group.
var relationuser= new GlideRecord('sys_user_grmember');
relationuser.addQuery('user',current.caller_id.toString()); //checking user from sys_user_grmember with caller
relationuser.addQuery('group','STARTSWITH','servicedesk');
relationuser.query();
while(relationuser.next())
{
var gname=relationuser.group.getDisplayValue(); //convert sys_id to readable text
if(gname.search('ServiceDesk') > -1 || gname.search('Service Desk') > -1) //contain group name contain service desk
{
current.assignment_group=relationuser.group;
current.u_servicedesk_relevant=true;
current.u_first_call_resolution=true;
}
}