How to compare manager of requested_by with assignment group manager .need to check if both the managers are same or not.Thanks you!

Alikutty A
Tera Sage

Hi,

You can try this out.

var group_rec;
var glide = new GlideRecord('sys_user_group');
glide.addQuery('group', record.assignment_group);
glide.query();

while (glide.next()) {
  group_rec = glide.group;
  var group = new GlideRecord('sys_user_group');
  if(group.get(group_rec)){
    //group object can be accessed here by dotwalkin on group variable
     gs.info("Name: "+group.name);
  } 

}

 

ARG645
Tera Guru

Simply Query the sys_user_group table as below, if all you wanted was a Group Object by a sys_id of the Group. 

var groupGr = new GlideRecord('sys_user_group');
groupGr.get(record.assignment_group);
ig(groupGr){
  var group_rec = groupGr;
}

Inactive_Us1474
Giga Guru

Use any of the below two ways. 

var id = ""; // sys_id of the group

var gr = new GlideRecord('sys_user_group');

gr.addQuery('sys_id',id);

gr.query();

if(gr.next()) {

gs.info('Group Object - '+gr);

}

-------

var id = ""; //sys_id of the group

var gr = new GlideRecord('sys_user_group');

gr.get(id);

gs.info('Group Object' +gr);

DirkRedeker
Mega Sage

Hi

Your script looks good. So, the reason, why it does not work is, that

a) "record" does not contain a valid GlideRecord

b) "record" does not have the field "assignment_group"

c) the value of the field "assignment_group!" does not have a Relation to the "group" table, but maybe has only a String

 

Can you confirm, that the above three points are correct?

Let me know, if that solved your issue, and mark my answer as correct and helpful,please.

 

BR

Dirk