How can we use objects with get() ?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2022 09:30 AM
Hi All,
I know the general usage of get().
var returnValue = grIncident.get('caller_id.name’,’Jane Doe’);
or
var returnValue = grIncident.get('57af7aec73d423002728660c4cf6a71c’);
But in the ServiceNow documentation it is defined as:
GlideRecord - get(Object name, Object value)
Product Documentation-GlideRecord - Global
and I never used get() with objects. Have you ever used it? Could you please give me an example?
Thanks
Oya
Labels:
5 REPLIES 5

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2022 02:18 AM
Hi Hitoshi,
Thanks for your response.
I have tested the code below:
var grUser = new GlideRecord('sys_user');
if (grUser.get('62826bf03710200044e0bfc8bcbe5df1')) {
var grCompany = new GlideRecord('core_company');
grCompany.query("sys_id", grUser.company);
while (grCompany.next()) {
gs.info(grCompany.name);
}
}
query() also accepts grUser.company. But in Help document it says query() accepts string. That's why I think whether object is something different here. Please have a look to my response to Joni.