- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 08:16 AM - edited 09-13-2023 08:18 AM
Hi All,
I had a list of assignment group sysid (around 10 assignment groups )in system property and I need to add a query in glide record to check the assignment group is one of those from the property. I am using only script include to do that and the below code is not working.
var prob=new GlideRecord("problem");
var getGrp = gs.getProperty('xyz_Assignmentgroups');
var spl = getGrp.split(',');
for (var i = 0; i < spl. Length; i++)
{
var sgroup=spl[i];
gs.log("xyz sgroup"+sgroup);
prob.addQuery('assignment_group',sgroup);
}
prob.query();
while prob.next()
{
....
}
This is not working ,the add query of assignment group condition is not working. Not sure how to add the query to check the sysid's is one of those assignment group from system property in script include.
Anyone can please help me on this
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 06:41 AM - edited 09-14-2023 06:41 AM
Hi @Sangeetha8,
You can put query like below
var groups = gs.getProperty('test_assignment_group_list');
var grGroup = new GlideRecord('problem');
grGroup.addEncodedQuery("assignment_group.sys_idIN" + groups);
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 08:54 AM
Your queries will be ANDed unless you use addOrCondition() starting at the second sys_id. Right now you're looking for rows where the assignment group is both spl[0] and spl[1].
Another way to write it would be to join() your array (after trimming each element of course) into an encoded query. First you have to preprend each array element with "assignment_group=", and then join the elements with "^OR", and then call addEncodedQuery().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 09:52 AM
Hello @Sangeetha8 ,
Please use below script and it should resolve you issue.
Kindly mark my answer as Correct and helpful based on the Impact.
Regards,
Siddhesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 06:34 AM
Thanks for your reply,
I tried this method but still it is not working. I want to check assignment group is one of condition.
Do you have any idea on this how to add assignment group is one of from the system property.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 06:41 AM - edited 09-14-2023 06:41 AM
Hi @Sangeetha8,
You can put query like below
var groups = gs.getProperty('test_assignment_group_list');
var grGroup = new GlideRecord('problem');
grGroup.addEncodedQuery("assignment_group.sys_idIN" + groups);
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates