Unable to read sys_id

trinadhgottipat
Kilo Expert

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.

6 REPLIES 6

Kishor kumar1
Mega Expert

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);




find_real_file.png



script include



find_real_file.png



So result is


find_real_file.png



Thanks,



Kishor


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.


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().



find_real_file.png


result


find_real_file.png



Thanks,



kishor


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?