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
Gajanan KadamGajanan Kadam 

How can i pass error message on salesforce record by apex code in process builder.

I wrote a process builder in order to add an error message on the record details page.   

I am calling apex class in order to add a message on page 

public class AutoConvertLeads {
@InvocableMethod
public static ProcessMethod(List<Case> Caselist) {
for (Case clist:Caselist){
    clist.addError('error');
}
}
}

Could you please help me with this.

Thanks,
Gajanan
Raj VakatiRaj Vakati
Try like this
 
public class AutoConvertLeads {
@InvocableMethod
public static  String ProcessMethod(List<Case> Caselist) {
for (Case clist:Caselist){
	try{
		//clist.addError('error');
	}catch(Exception e){
return ' Error' ;
	}
}
}
}