Some PDIs are currently unavailable, and PDI actions are paused. View the latest updates here. Read More

can we call script include from business rule?

snajaykumar1234
Kilo Expert

if its yes, give me a example...

thanks

sanjay

10 REPLIES 10

Not applicable

lSurya 24
Giga Guru

Hello Sanjay,



Yes you can call script include from a business rule.



ex:


  1. function onAfter(current, previous) {  
  2.       var wsClient = new scriptincludenamehere();  
  3.       wsClient.process();  
  4.  
  5. }


Below links will be handy,


How to execute script include from business rule


Problem calling a Script Include from a Business Rule


Using Business rule to run script include in the background


parvinder2
Kilo Guru

Yes you can call.



BR :



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


 


  var obj = new SI name();


  SIname.functionname(current, previous);


})(current, previous);



use SI : SI name




var SI name= Class.create();


SI name.prototype = {


  initialize: function() {


  },



functionname: function(current, previous) {


          try {


                                                                                           


    }


      catch(e) {


                  gs.log(e.message);


  }



Please mark correct and helpful.



Regards,


Parvinder


snehabinani26
Tera Guru

Hi Sanjay,



To execute a script include from Br you just need to create an object of that script include(which is typically a class) and call the function of that script include with the object.



eg, script include - MyScript


function in the script incldue - myfunction()



in the Br just write


var x=new MyScript();


x.myfunction();