business rules

SIVAKARTHICS
Tera Contributor
   
    var gr = new GlideRecord("x_1622035_meeting_request_room");
    gr.addQuery("room_no" , current.variables.room_name.name);
    gr.addQuery("start_date" , "<=" , current.variables.end_date);
    gr.addQuery("end_date" , ">=" , current.variables.start_date);
    gr.query();
      if(gr.next()){
        gs.addErrorMessage('This room is already booked for the selected time range');
        current.setAbortAction(true);
       
    }
 
 
this is my code when the above comdidtion satisfies my catlog must not be submitted . but in my code the error message alone displaying and my catlog item is also submitting . how to i abort these these submitting action 
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@SIVAKARTHICS 

you have written this in business rule?

please use onChange catalog client script on both the variables and use GlideAjax and then throw field message error if validation fails.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@SIVAKARTHICS 

you have written this in business rule?

please use onChange catalog client script on both the variables and use GlideAjax and then throw field message error if validation fails.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader