Simple Business Rule to check if a True/False is selected or not

ShivangiC
Tera Contributor

I am trying to create a simple BR to check if a checkbox box field is selected or not. BR is running After Insert & Update. Below is my code, which is not running at all [I want to achieve this requirement using Business Rule only] :-

 

(function executeRule(current, previous /*null when async*/) {
    gs.addInfoMessage('BR for CheckBox is running');
    if(current.u_agree == true){
        gs.addInfoMessage('Checkbox is selected');
    }
    else{
        gs.addInfoMessage('Checkbox is NOT selected');
    }

})(current, previous);
 
 
I tried using gs.log() also but in logs I found this message 'Invalid query detected, please check logs for details [Unknown field null in table u_student_scores_sc]'
Whereas the field name mentioned in the query is correct
6 REPLIES 6

akyadav
Tera Expert

Hi @ShivangiC change your BR type to Before, it will work 😊

Brad Bowman
Kilo Patron
Kilo Patron

Good work adding the logs.  If you are not seeing any of them, do you have a Condition on the Advanced tab or any Filter Conditions? Is u_student_scores_sc the name of a field on whatever table this is running on?  This could be an unrelated/coincidental log if there are other Business Rules running after insert/update - whichever you are using in your test case.