Functions in a Business Rule

Geeky
Kilo Guru

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?

 

5 REPLIES 5

Jon Ulrich
Kilo Guru

What do you want to do with the value at the end?

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.

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()

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?