current not available in script action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2016 08:16 AM
Hello Community
I'm working with a script action to respond to an event I have being triggered in the system. As I understand it from reading the wiki → Script Actions - ServiceNow Wiki � the script action already has knowledge of what current is. In my script action, i have gs.log("Current : " + current) and gs.log("Current ID : " + current.sys_id) and both are showing undefined in the logs. Any idea why current doesn't work here?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2016 08:20 AM
Did you schedule an event? Can you share your script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2016 08:31 AM
var json = new JSON();
var parameterOne = (isJSON(event.parm1) == true) ? json.decode(event.parm1) : event.parm1;
createIncident(parameterOne);
gs.log("CURRENT : " + current.sys_id + " - " + current.number);
var recordTextHeader = "Record Information\n";
var tableName = "Table : Unable to determine the source table.\n";
if(current.sys_class_name != ""){
tableName = "Table : " + current.sys_class_name + "\n";
}
var recordNumber = "Number : Unable to determine record number.\n";
if(current.number != ""){
recordNumber = "Number : " + current.number.toString() + "\n";
}
var uniqueID = "Unique ID : Unable to determine the sys_id of the source record.\n";
if(current.sys_id != ""){
uniqueID = "Unique ID : " + current.sys_id.toString() + "\n";
}
var item = "Item : Unable to determine what item was requested.\n";
if(current.sys_class_name == "sc_req_item"){
if(!current.cat_item.nil()){
item = current.cat_item.getDisplayValue() + "\n";
}
}
If by schedule an event, you mean register an event, yes I have.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2016 08:35 AM
"custom.error" should be scheduled in a business rule? Did you schedule this event in a business rule on a table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2016 08:40 AM
I'm not sure I follow what you mean by "scheduling" the event. I'm calling the event from a script include where I'm looping through some user records. If, during that loop, I detect a duplicate record, I trigger my event. Which in turn, I would expect to trigger my Script Action. Can you elaborate on what you mean by "schedule" the event?