Calling Script Include in Business rule

mohammedhyderal
Kilo Contributor

Hi All,

I have a requirement of calling a script include from the business rule,

Let me explain the complete requirement

1) I have created a test variable in one of the catalog item

2) whenever the test variable is set to complete, Only then the business rule should trigger

3)I need to call the script include if the test variable is set to complete

Thanks in advance

7 REPLIES 7

Chuck Tomasi
Tera Patron

HI Mohammed,



Without any details, I can offer you only general constructs.



Use the business rule condition statement to check the variable value. Your business rule would use elements similar to the following:



Condition: current.variables.variable_name == 'true'



Script:


(function executeRule(current, previous /*null when async*/) {



        // instantiate and call your script include here


        var si = new MyScriptInclude();


        si.myMethod();



})(current, previous);


Thanks Tomasi,



WIll try and let you know..


It should run only on a particular catalog item,



For example : Test Catalog



Should i add the condition?


Yes, you need to add the condition to check for that particular catalog item. I'll assume your business rule is on the Requested Item (sc_req_item) table. In that case,



current.cat_item.name == 'Name of your catalog item'



needs to be added to the condition to prevent it from running on other catalog items.