Using getValue() to Get Assignment_group.name On sys_user_group Table

JosephW1
Tera Guru

I am trying to return the string of the queried group with the following code, but it always returns NULL. If I change the getValue('name') to getRowCount(), then it returns 1, showing that the query itself is working but the getValue is not. As well as using 'name', I also tried group, assignment_group, and assignment_group.name, but none of them worked either. I also tried getDisplayValue('name') and getElement('name'), but those did not work.

I am using the Widget Editor, and my entries are as follows:

 

Server Script

(function(){
var groups = new GlideRecord('sys_user_group');
groups.addQuery('name', 'Database Atlanta');
groups.query();
data.test = groups.getValue('name');
})();

HTML Template

<div class="info">
Groups Output: {{ data.test }}
</div>

 

Please, what do I need to change the .getValue('name') to in order to return the string value of the group's name?

 

Kind Regards,

Joseph

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

try now

 

(function(){
var groups = new GlideRecord('sys_user_group');
groups.addQuery('name', 'Database Atlanta');
groups.query();
if(groups.next()){
data.test = groups.getValue('name');
}
})();

View solution in original post

7 REPLIES 7

glad i helped you. 

 

you can go though the doc link which i had shared in my response. it has explained very well

 

Hit my response as helpful as well. so i can get some points 😛 

Thanks, I'll look through it!

Harsh Vardhan
Giga Patron

you need to use next() to iterate the record value. 

 

refer the doc link for further details about glide record

 

https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=r_GlideRecord-next