Trigger to fetch detail of other parent through junction object | Trigger AddError alternate through Exception


In this post we are going to write Trigger to fetch details of other parent through Junction object. We will write Trigger on "ServiceAppointment" which is parent of "AssignedResource" object which will check if Assigned Resource have previous open Service Appointment with it. Here one more object is there which is "ServiceResource". AssignedResource object is junction object. So one user can be assigned in many service appointment. We need to traverse to "ServiceResource" which can give the details of all AssigendResource which is associated with it and hence we can find all the ServiceAppointment related with it and lastly we can check which is still open.
In this post we will also see the Trigger AddError alternate i.e Custom Exception. From Custom Exception we can show the error message, but remember we cannot show the error message through Apex.Message()

Reactions

Post a Comment

0 Comments