How to get the sys_id of the current record in an Indicator Script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2017 01:00 AM
Hi,
Is there a way to get the "sys_id" available in the Field (field_list) or directly in the script on the Script form in PA?
It's not possible to select "sys_id" in the available fields on the Script form in PA to use it in the Script. This is needed to query the cmdb_rel_ci for some validations for the current record.
The following structure is built in PA:
1) Created Indicator Source on Facts table: Database Instance [cmdb_ci_db_instance]
2) Created an Indicator for this Indicator Source: "# of pass DB instances for platform validation".
Indicator details:
Aggregate: SUM
Scripted: checked
Script: SH.Validate DB platform relation
Script details:
Source:
Remark: In the Available field list is sys_id not visible.
Script:
checkPlatformforDBInstance(current);
function checkPlatformforDBInstance(record){
var rValue = 0;
var sysId = record.sys_id; //sys_id is not available..
var vTable = 'cmdb_rel_ci';
var vCol;
var vStrQuery ='parent='+sysId;
if(sysId != ''){
var grVal = new GlideRecord(vTable);
grVal.addEncodedQuery(vStrQuery);
grVal.query();
while(grVal.next()){
if(grVal.child.sys_class_name == 'cmdb_ci_win_server'){
rValue = 1;
}
}
}
return (rValue);
}
Dirty workaround: There is a dirty way (add sys_id in XML and import Script record in ServiceNow) to make sys_id available in the script area, but this is not the preferred way forward.
Another approach: This report can also be created with a database view, but I don't want to do this.
Hopefully, someone is able to help me with this issue!
Cheers,
Serkan
- Labels:
-
Performance Analytics

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2017 02:01 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2017 02:16 AM
Gaurav,
You are mentioning the sys_id of the record self, but I'm talking about the current record in the indicator.
Cheers,
Serkan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2017 02:20 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2017 02:26 AM
Nice way to make Sys id available arnoud!
Sys id is with this method and XML load temporary available, after an update the value is not in place anymore...