Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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

Priyanka0402
Mega Sage

   Hello @ShivangiC ,

Try replacing    if(current.u_agree == true)  with   if(current.u_agree) or  if(current.u_agree == 'true') ; 

 

Hello @Priyanka0402 ,

That I will replace but why even after Saving the record, the info message  gs.addInfoMessage('BR for CheckBox is running'); is not displaying. It means my Business Rule is not running. And I am unable to find the reason behind it

Sid_Takali
Kilo Patron

Hi @ShivangiC Try below code and try to add logs to debug 

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

    gs.info('BR for CheckBox is running');

    if (current.u_agree) {
       gs.log("Inside If");
        gs.info('Checkbox is selected');
    } else {
       gs.log("Inside Else");
        gs.info('Checkbox is NOT selected');
    }
      gs.log("Outside if else");

})(current, previous);

Hello @Sid_Takali,

I tried your code but in Logs I am getting error message. Screenshot attached below. I had already tried gs.log(), same message I was also getting. But Iam not understanding what actually it means.