Addquery multiple fields to reference in script

coreyo
Giga Contributor

I think I am close.   I want to prevent a user from using an (inactive) value/name in the group. (Normally being pulled from their templates).   Here is my script:

var gr = new GlideQuery('groups');

gr.addQuery('name',current.assignment_group.getDisplayValue());

gr.addQuery('active');

gr.query();

if (gr.active == false) {

      gs.addInfoMessage('This group is not active, please update your template accordingly');

      current.assignment_group.setError('This group is not active, please update your template accordingly');

      current.setAbortAction(true);

  }

1 ACCEPTED SOLUTION

My bad. I found the error. It was line no 1


Here is the updated code.


var gr = new GlideRecord('sys_user_group');  


gr.addQuery('sys_id',current.assignment_group);  


gr.addQuery('active', true);  


gr.query();  


if(!gr.next()) {  


      gs.addInfoMessage('This group is not active, please update your template accordingly');  


      current.assignment_group.setError('This group is not active, please update your template accordingly');  


      current.setAbortAction(true);  


  }  



View solution in original post

11 REPLIES 11

That was it!   Thank you again for walking me through this!


You are very welcome. Thanks for participating in the community!