- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 09:03 PM
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.
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'];
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 09:26 PM - edited 02-19-2024 09:29 PM
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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 09:22 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 09:26 PM - edited 02-19-2024 09:29 PM
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:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 09:29 PM - edited 02-19-2024 09:30 PM
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!