We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. 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

hvrdhn88
Giga Patron

Hi Sanjay,



yes you can call. as you call any function same way you can call it.



var myCustomClass = Class.create();  


myCustomClass.prototype = {  


      initialize: function() {  


      },  


         


      myCustomFunction: function () {  


      ...  




Business rule should look like :



var myVariable = new myCustomClass();  


myCustomClass.myCustomFunction();  


Masarrat Siddi1
Kilo Guru

Server Side Script include can be called in BR. 

 

 

Thank You

Masarrat Siddiqui

Swarup Patra
Kilo Guru

var ApprovalEntitlementUtil = Class.create(); ApprovalEntitlementUtil.prototype = { initialize: function () { }, //on create approval, return the entitlement status returned by licensing API here onCreateApproval: function (usersysid, tablename) { try { var isEntitled = new sn_lef.GlideLicenseAPI().canUserApproveOnTable(usersysid, tablename); return isEntitled; } catch (e) { gs.log("Error with onCreateApproval: GlideLicenseAPI failure."); } }, //on adjudicate approval, return the entitlement status returned by licensing API here onAdjudicateApproval: function (usersysid, tablename) { try { var isEntitled = new sn_lef.GlideLicenseAPI().enableEntitlementLogging().canUserApproveOnTable(usersysid, tablename); return isEntitled; } catch (e) { gs.log("Error with onAdjudicateApproval: GlideLicenseAPI failure."); } }, type: 'ApprovalEntitlementUtil' }; nowKB.com

Harish Bainsla
Kilo Patron

Hi check below video you will understand

https://youtu.be/T9x4ZXAVurE?si=JfAzALO6S8RBCqYP

Swarup Patra
Kilo Guru

var ApprovalEntitlementUtil = Class.create(); ApprovalEntitlementUtil.prototype = { initialize: function () { }, //on create approval, return the entitlement status returned by licensing API here onCreateApproval: function (usersysid, tablename) { try { var isEntitled = new sn_lef.GlideLicenseAPI().canUserApproveOnTable(usersysid, tablename); return isEntitled; } catch (e) { gs.log("Error with onCreateApproval: GlideLicenseAPI failure."); } }, //on adjudicate approval, return the entitlement status returned by licensing API here onAdjudicateApproval: function (usersysid, tablename) { try { var isEntitled = new sn_lef.GlideLicenseAPI().enableEntitlementLogging().canUserApproveOnTable(usersysid, tablename); return isEntitled; } catch (e) { gs.log("Error with onAdjudicateApproval: GlideLicenseAPI failure."); } }, type: 'ApprovalEntitlementUtil' }; nowKB.com