Gs.addErrorMessage gives error message multiple times

Community Alums
Not applicable

Hi Team,

 

I have a query I have written a before update BR, and I am comparing the date field. but I am getting the error message multiple times if the condition meets?

 

 

Ankur20_0-1710752283813.png

 

 

Ankur20_2-1710752372739.png

 

 

2 ACCEPTED SOLUTIONS

mhegde1
Kilo Sage

Hi @Community Alums ,

 

If multiple records are updating at a time then yes above error msg will show those many times.

 

thanks,

View solution in original post

Robbie
Kilo Patron
Kilo Patron

Hi @Ankur20,

 

A query business rule can legitimately be called multiple times meaning the message will appear (and be duplicated) each and everytime, however, a good way to make sure the cache is clear is to leverage the below syntax:

 

gs.flushMessages()

 

Call this before your gs.addErrorMessage() call.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Thanks, Robbie

View solution in original post

5 REPLIES 5

Robbie
Kilo Patron
Kilo Patron

Hi @Ankur20,

 

A query business rule can legitimately be called multiple times meaning the message will appear (and be duplicated) each and everytime, however, a good way to make sure the cache is clear is to leverage the below syntax:

 

gs.flushMessages()

 

Call this before your gs.addErrorMessage() call.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Thanks, Robbie