Unable to read sys_id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2017 12:30 AM
Hello,
I'm having a businddess rule on Task table,which gets executed when the Script Include which is given in the condition field evaluates to true.
But, in my SCript Include, i'm passing the params from the business rule condition itself.
When the script include is called it is unable to read my record object.sys_id.So its returning an exception
Exception (TypeError: Cannot read property "sys_id" from null (sys_script_include.37f814d06ffa220025c42fceae3ee425.script; line 9)) occured while evaluating'Condition: javascript:new AffectedUtils().hasAffected(current, "task_ci", "task");' in business rule 'Affected ci notifications' on problem:PRB0001391; skipping business rule
How can I overcome this.Any ideas?
TIA,
Trinadh.
- Labels:
-
Problem Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2017 01:11 AM
Hi,
Check the passing object
Your object should be:
Business rule:
var object_ = {name:'Kishor', sys_id:'sdf78983876fdsdf0io', passing:'true'};
var script_include_name = new testing_from_bus().test(object_);
gs.addInfoMessage(script_include_name.sys_id);
script include
So result is
Thanks,
Kishor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2017 01:54 AM
MY SCRIPT INCLUDE
NAME : AffectedUtils
var AffectedUtils = Class.create();
AffectedUtils.prototype = {
initialize: function() {
},
hasAffected : function(taskGR, table, field) {
var affectedGR = new GlideRecord(table);
affectedGR.setLimit(1);
affectedGR.addQuery(field, taskGR.sys_id);
affectedGR.query();
if (affectedGR.getRowCount() > 0)
return true;
return false;
},
type: 'AffectedUtils'
};
BUSINESS RULE
NAME : Affected group notifications
CONDITION : javascript:new AffectedUtils().hasAffected(current, "task_group", "task");
This is my scenario.Current objects sys_id is treated as null.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2017 02:01 AM
Hi,
Here is the problem we can't pass the 'current' it work as 'this' parameter.
javascript:new AffectedUtils().hasAffected(current.getUniqueValue(), "task_group", "task");
Your using sys_id of the record then pass only sys_id using current.getUniqueValue().
result
Thanks,
kishor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2017 02:08 AM
Thought the same.Just wanted to confirm.But my concern here is this Business Rule and script include are configured long back,a couple of years ago.But why is the problem rising now?