How to check the list of assignment group from system property in script include?

Sangeetha8
Tera Contributor

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.

 

        

 

1 ACCEPTED SOLUTION

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);

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

9 REPLIES 9

Thanks Vishal ,It is working.

Do you know how to do for excluding the assignment group is not one of condition from the system property in simple way without using for loop

Hi Sangeetha

 

Unfortunately for excluding we can do it one at a time only.

 

gr.addEncodedQuery("assignment_group.sys_id!=" + <sys_id>)

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Hi @Vishal Birajdar 

I have created system property with multiple sys_id of assignment group values, And call system property using g_scratchpad in display BR.

I need to write on change client script based on the change of Assignment group I need to show in dropdown choices.

 

if(group a, group b, group c)

able to see certain choices

else if(group b, group d, group e)

certain choices

I'm using conditon 

if(myProperty.indexOf(newValue)>-1)
using this all sys_id pass in system property working fine
but I need to add more condition for if(group b, group d, group e) what condition I need to use?

 

Hi @Pushpanjali2 

 

If possible can you share some screenshot of your code...??

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Pushpanjali2_0-1725461645771.pngPushpanjali2_1-1725461745398.pngPushpanjali2_2-1725461850646.pngPushpanjali2_3-1725461891637.png

around 70 choices I need to add in loop based on the assignment group I need to visible choices. I have tried with SI also but didn't got result any other way if we have in bulk we can visible  choices?

I need to show choices in drop down on change of assignment group - I have posted question but no reply yet