Missing function declaration for onBefore error on Business Rule

mitzaka
Mega Guru

Hi SNC,

I am trying to write a Business Rule but whatever I do I get this message: Missing function declaration for onBefore.

I am on Fuji, and have never seen this so far.


Would appreciate any tips on what I am doing wrong.

1 ACCEPTED SOLUTION

Harish KM
Kilo Patron
Kilo Patron

Hi..


  In fuji, write the code inside that function



function onBefore(current, previous) {


    //This function will be automatically called when this rule is processed.



// your code here


}




or



function onBefore(current, previous) {


    //This function will be automatically called when this rule is processed


}


// your code here



Thanks'


Harish


Regards
Harish

View solution in original post

19 REPLIES 19

Do you know if there's something weird where business rules created before upgrading to Helsinki aren't allowed to use the Helsinki format?   Because I'm trying to change it to use that instead of onAfter and it's giving me that Missing function declaration for onAfter


bcronrath, have you put the code inside like this:



(function executeRule(current, previous /*null when async*/) {



  // Add your code here


})(current, previous);



?


My guess is that older stuff still work, but if you trying to change them and save, they need to be in the "new" format.



//Göran


That's the exact code I'm trying to put but it keeps telling me Missing function declaration for OnAfter, whenever I try to edit older business rules.   It lets me save that type of code just fine newly created ones (it defaults to this style of code)


See my "mini-revelation" from 6/13 above:



On a related note, I just realized that there's now an "Execute Function" field on business rules deciding whether or not these functions will be automatically run. (If you also get the crazy idea to try manually converting a pre-Fuji business rule to the new approach, make sure you set this field to true!)



It sounds like you may need to check that box.


Ah ha, I just re-read your original issue. Maybe you actually had to un-check that box when switching to the generic (executeRule) function? (I assume it was still checked/"true", so the system was looking in your script for an onAfter function, which you had just removed.)