+ 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

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.

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.