function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
fvrfvsrtbb rtfvrfvsrtbb rt 

addError in trigger does nothing in service cloud console when editting records

trigger CheckPhoneFields on Contact (before update) {
  for (Contact contact: System.Trigger.new)
  {
      if (contact.Phone != null && contact.Phone.length() > 20)
        contact.Phone.addError('Too many digits ('+contact.Phone.length()+').  20 max.');
  }
}

This code works for inline editting, it does not save the changes and it displays the error.   Full page editing in the service cloud console does not display the error.

What is wrong here?

Prathyu bPrathyu b
Hi,

Your code looks like perfect and when i try from my end its working in service console too.
So, could you re-check your console settings and update if you miss any.
Or share the console settings so, that i will check and let you know.

Thanks
Prathyu
 
Sumeet_ForceSumeet_Force
I tried in my console and it worked right. Are you sure - you are editing the record and not just testing new record creation (as trigger is just for update) ?
Akash Rai 1Akash Rai 1
Put System.debug() at the palce of  addError and check, Is it print the text in the log. If not, then there will be problem in condition or You are not doing update operation.