Convert this addEncodedQuery to an addQuery

MBarrott
Mega Sage

More of a learning opportunity than anything. I was struggling to decipher the breadcrumb logic for this query and instead had to opt for an addEncodedQuery instead. 

 

If I were to use addQuery, how would I accomplish this?

 

var grStakeHolReg2 = new GlideRecord('dmn_stakeholder_register');
grStakeHolReg2.addEncodedQuery('sys_class_name=dmn_stakeholder_register^user.active=false');  // this line here
grStakeHolReg2.query();
while(grStakeHolReg2.next())
{
	gs.log('inactive user is: ' + grStakeHolReg2.getDisplayValue('user'));
}
1 ACCEPTED SOLUTION

swathisarang98
Giga Sage
Giga Sage

Hi @MBarrott ,

 

It would be something as below,

 

grStakeHolReg2.addQuery('sys_class_name','dmn_stakeholder_register');
grStakeHolReg2.addQuery('user.active', false);

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

 

View solution in original post

3 REPLIES 3

Sumanth16
Kilo Patron

Hi @MBarrott ,

You already querying dmn_stakeholderregister table. I think you don't need sys class name query.

 

 

var grStakeHolReg2 = new GlideRecord('dmn_stakeholder_register');
grStakeHolReg2.addQuery('sys_class_name=dmn_stakeholder_register')
grStakeHolReg2.addQuery('user.active=false');  // this line here
grStakeHolReg2.query();
while(grStakeHolReg2.next())
{
	gs.log('inactive user is: ' + grStakeHolReg2.getDisplayValue('user'));
}

 

 

servicenow.com/community/developer-forum/dotwalk-in-glide-addquery-possible/m-p/1546170

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

 
 

swathisarang98
Giga Sage
Giga Sage

Hi @MBarrott ,

 

It would be something as below,

 

grStakeHolReg2.addQuery('sys_class_name','dmn_stakeholder_register');
grStakeHolReg2.addQuery('user.active', false);

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

 

Hi @swathisarang98,

 

This worked perfectly and was exactly what I was looking for, thank you!