Paasing Variable to BR

ABC6
Tera Contributor

Hello Team,
I am not sure how to pass this Script include variable to Business Rule ,Please Suggest me i am new to this forum.

ABC6_0-1708405391861.png

 

SI

var TestVal = Class.create();
TestVal.prototype = {
initialize: function() {
},
type: 'TestVal'
};
TestVal.base_Class=['incident','task_sla'];
TestVal.priorities= ['1','2'];
TestVal.not_allow_message=['Not Sending Message'];

1 ACCEPTED SOLUTION

Nick Parsons
Mega Sage

Hi @ABC6 , you've defined your values as "static" properties of your class. To access them in a business rule, access the Script Include from within your business rule like so:

 

 

// Your business rule code
gs.info(TestVal.base_Class); // incident,task_sla
gs.info(TestVal.priorities); // 1,2
gs.info(TestVal.not_allow_message); // Not Sending Message

 

 

Note that if your script include is in a scoped app, then you should prefix the script include access with your app name (which will look something like x_<vendor_name>_<app_name>) for example x_abcd1_travel_mgmt.TestVal. Simiarly, if your script include is in the global scope, but your business rule is in scoped, then you can prefix global to your script include: global.TestVal. You can look at the API Name on your script include to get the correct prefix to use within your business rule:

NickParsons_0-1708406958366.png

 

View solution in original post

3 REPLIES 3

Danish Bhairag2
Tera Sage
Tera Sage

Hi @ABC6 ,

 

What is ur requirement or what are you trying to achieve here? As I could see in script include the values are hard-coded. If u hardcoding the values better to use in ur BR directly.

 

Thanks,

Danish

Nick Parsons
Mega Sage

Hi @ABC6 , you've defined your values as "static" properties of your class. To access them in a business rule, access the Script Include from within your business rule like so:

 

 

// Your business rule code
gs.info(TestVal.base_Class); // incident,task_sla
gs.info(TestVal.priorities); // 1,2
gs.info(TestVal.not_allow_message); // Not Sending Message

 

 

Note that if your script include is in a scoped app, then you should prefix the script include access with your app name (which will look something like x_<vendor_name>_<app_name>) for example x_abcd1_travel_mgmt.TestVal. Simiarly, if your script include is in the global scope, but your business rule is in scoped, then you can prefix global to your script include: global.TestVal. You can look at the API Name on your script include to get the correct prefix to use within your business rule:

NickParsons_0-1708406958366.png

 

Service_RNow
Mega Sage

Hi @ABC6 

You can create a variable in the first business rule, if you declare it outside of the function it will be available to other business rule with higher run order.

User-defined variables are globally scoped by default. If a new variable is declared in an order 100 business rule, the business rule that runs next at order 200 also has access to the variable.

follow thread it will be helpful

can-script-includes-use-the-current-variable 

 

var brOneTriggered = true;

 

And in the second business rule check the value of it like this:

 

if (!brOneTriggered) {
    // Do something I don't want to happen when BusinessRuleTwo was triggered BusinessRuleOne
 }

 

Please mark reply as Helpful/Correct, if applicable. Thanks!