Functions in a Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2018 07:11 AM
Can I write a function in business rule and pass a value to it and return something? Or Is it required to use a script include for this? I know script include can be used for routine codes but just wonder if we can achieve it in business rule as well.
In my business rule, I am having different location on a different conditions. Location value could be different for different conditions but logic for scripting a location would be same. Here what I am trying in my BR but its not working.
If ( case 1){
setLocation(var1);}
if (case 2){
setLocation(var2);}
function setLocation(loc)
{
some scripting with loc;
return value;
}
Any suggestions?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2018 07:26 AM
What do you want to do with the value at the end?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2018 07:28 AM
Assign it to some field where it will be shown to the user. I can assign it in the function itself instead of returning it. That's not a problem here.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2018 07:57 AM
If you are running the code server side and want to make it into a script include, you could do...
current.u_my_field = new myScriptInclude().myFunction()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2018 07:59 AM
Yes, I understand that I can achieve it through script include but just wondering if I can declare a function inside a business rule and call it from the same business rule?