+ Start a Discussion
sreedharp286sreedharp286 

Trigger code for display error message , when ever trying to case status field updated

 Can any one send trigger code ?

 

Best Answer chosen by Admin (Salesforce Developers) 
jungleeejungleee

You can use the below code to throw error whenever there's a change in the status. But this could have been achieved from a validation itself.

 

trigger caseStatusUpdate on case (before update){
	for(case c: trigger.new){
		if(c.status!= trigger.oldMap.get(c.id).status){
			c.status.addError('you cannot update the status');
		}
	}
}

 

 

All Answers

jungleeejungleee

You can use the below code to throw error whenever there's a change in the status. But this could have been achieved from a validation itself.

 

trigger caseStatusUpdate on case (before update){
	for(case c: trigger.new){
		if(c.status!= trigger.oldMap.get(c.id).status){
			c.status.addError('you cannot update the status');
		}
	}
}

 

 

This was selected as the best answer
Abhi_TripathiAbhi_Tripathi

Hey sreedharp, 

 

In the below link there is a code sample having same thing as in your requirement

 

 

http://abhithetechknight.blogspot.in/2013/09/custom-error-message-on-standard-edit.html