-3

How to display custom error message, when i do not fill the required input fields it will show custom error message.I don't want this standard message(Error: You must enter a value). please give me some ideas

MMM
  • 15
  • 5

1 Answers1

0

try to use addError method.

Refer to this : https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_sobject.htm

Tejas Kapasi
  • 155
  • 1
  • 4
  • 12
  • Hi, Tejas Kapasi give me one example – MMM May 05 '15 at 06:36
  • Hi, Simple Example would be like this, `code Contact cont = (Contact) stdctrl.getRecord();

    if( (String.IsBlank(cont.Email) && (String.IsBlank(cont.phone) ){ cont.email.addError('Please Enter an email Address or Phone Number'); cont.phone.addError('Please Enter a Phone number or Email Address'); }else{ // do something

    } `

    – Tejas Kapasi May 05 '15 at 07:51
  • `for (Contact cand : contacts) { if ( (null==cand.Email || cand.Email.length()==0) && (null==cand.Phone || cand.Phone.length()==0) ) {

    cand.email.addError('Either email or phone must be defined'); cand.phone.addError('Either email or phone must be defined'); } `

    – Tejas Kapasi May 05 '15 at 08:02