- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 10:05 AM
Hi,
please assist me to get sys_id of name field instead of string.
var configurationitem;
var gr1 = new GlideRecord('cmdb_ci_win_server');
gr1.addEncodedQuery('fqdn=' + hostname);
gr1.query();
if (gr1.next()) {
configurationitem = gr1.name;
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 10:23 AM - edited 01-23-2024 10:24 AM
@Deepa12 Please update your script as follows.
var configurationitem;
var gr1 = new GlideRecord('cmdb_ci_win_server');
gr1.addEncodedQuery('fqdn=' + hostname);
gr1.query();
if (gr1.next()) {
configurationitem = gr1.getValue('sys_id');
}
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2024 12:31 AM
Tried this code as well
var configurationitem;
var gr1 = new GlideRecord('cmdb_ci_win_server');
gr1.addEncodedQuery('host_name=P1SAP');
gr1.query();
if (gr1.next()) {
configurationitem = gr1.sys_id;
}
gs.print(configurationitem);
it will give you sys_id.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 10:23 AM - edited 01-23-2024 10:24 AM
@Deepa12 Please update your script as follows.
var configurationitem;
var gr1 = new GlideRecord('cmdb_ci_win_server');
gr1.addEncodedQuery('fqdn=' + hostname);
gr1.query();
if (gr1.next()) {
configurationitem = gr1.getValue('sys_id');
}
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2024 12:31 AM
Tried this code as well
var configurationitem;
var gr1 = new GlideRecord('cmdb_ci_win_server');
gr1.addEncodedQuery('host_name=P1SAP');
gr1.query();
if (gr1.next()) {
configurationitem = gr1.sys_id;
}
gs.print(configurationitem);
it will give you sys_id.