- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-21-2020 12:42 AM
Hello,
Need to get sys_id of a server from server name.
I am using below script it is not working.
var tableGr = new GlideRecord('cmdb_ci_computer');
tableGr.addQuery('name', 'LAPTOP-AFB9NR12');
tableGr.query();
var sysId = tableGr.sys_id;
gs.print(sysId);
running this script , not getting any results..
Solved! Go to Solution.
- Labels:
-
Discovery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-21-2020 12:43 AM
Try this:
var tableGr = new GlideRecord('cmdb_ci_computer');
tableGr.addQuery('name', 'LAPTOP-AFB9NR12');
tableGr.query();
tableGr.next();
var sysId = tableGr.getUniqueValue();
gs.print(sysId);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-21-2020 12:43 AM
Try this:
var tableGr = new GlideRecord('cmdb_ci_computer');
tableGr.addQuery('name', 'LAPTOP-AFB9NR12');
tableGr.query();
tableGr.next();
var sysId = tableGr.getUniqueValue();
gs.print(sysId);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-21-2020 12:44 AM
Hi,
use the following script:
var tableGr = new GlideRecord('cmdb_ci_computer');
tableGr.addQuery('name', 'LAPTOP-AFB9NR12');
tableGr.query();
while(tableGr.next())
{
var sysId = tableGr.sys_id;
gs.print(sysId);
}
If I have answered your question, please mark my response as correct and/or helpful.
Thank you very much
Cheers
Alberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-04-2023 08:45 PM
Can we make such request via using mid?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-21-2020 12:55 AM
Hi,
I always use like this:
var tableGr = new GlideRecord('cmdb_ci_computer');
tableGr.addQuery('name', 'LAPTOP-AFB9NR12');
tableGr.query();
if(tableGr.next()){
var sysId = tableGr.getValue('sys_id');
gs.print(sysId);
}
Thanks,
Ashutosh