You need to sign in to do that
Don't have an account?
Edwin Vijay
getDmlMessage returning complete error message and not truncated one
Apex Code:
Error message:
OppLnItemTrigger: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 0064000000f8EeIAAU; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, The selected product does not exist in EDW yet.Please update your selection or try again later.: [] Class.TriggerHandlerBase.updateObjects: line 172, column 1 Class.TriggerHandlerBase.processObjects: line 61, column 1 Class.TriggerDispatcherBase.execute: line 128, column 1 Class.OppLnItemDispatcher.afterUpdate: line 78, column 1 Class.TriggerFactory.execute: line 43, column 1 Class.TriggerFactory.createTriggerDispatcher: line 19, column 1 Trigger.OppLnItemTrigger: line 2, column 1
I only want to display the error message: 'The selected product does not exist in EDW yet.Please update your selection or try again later'
Any help is appreciated. THANKS
try{ update(itemsToUpdate); showsuccess = true; } catch(DmlException e){ for(integer i=0; i < e.getNumDml(); i++){ ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,e.getDmlMessage(i))); } showsuccess = false; return null; }
Error message:
OppLnItemTrigger: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 0064000000f8EeIAAU; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, The selected product does not exist in EDW yet.Please update your selection or try again later.: [] Class.TriggerHandlerBase.updateObjects: line 172, column 1 Class.TriggerHandlerBase.processObjects: line 61, column 1 Class.TriggerDispatcherBase.execute: line 128, column 1 Class.OppLnItemDispatcher.afterUpdate: line 78, column 1 Class.TriggerFactory.execute: line 43, column 1 Class.TriggerFactory.createTriggerDispatcher: line 19, column 1 Trigger.OppLnItemTrigger: line 2, column 1
I only want to display the error message: 'The selected product does not exist in EDW yet.Please update your selection or try again later'
Any help is appreciated. THANKS
Try using
ApexPages.addMessages(e);
Please refer below post there are different solutions it may help you.
http://stackoverflow.com/questions/11607007/how-to-show-only-extracted-error-message-from-custom-validation-on-a-visualforce
Hope this helps you!
Please mark it as solved if this helps you so that it will make available for other as a proper solution.
Thanks and Regards
Sandhya