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
ipl bcciipl bcci 

Is it possible to write a single trigger on Multiple Objects

My Requirement:
 I have one custom profile (Test User)  and  one Custom Object.
 This profile having delete access on Opportunity,Contact and this Custom Object.
 Now I want to write a trigger to restrict user with ""Test User"" profile from deleting above mentioned   3 object records.

Or a sinlge apex class that will work on these 3 objects.

Thank you in advance
VinayVinay (Salesforce Developers) 
I dont think you can write single trigger on multiple object.  Kindly review below limitation.

https://ideas.salesforce.com/s/idea/a0B8W00000Gdkv4UAB/one-trigger-for-multiple-objects

Please mark as Best Answer if above information was helpful.

Thanks,
Maharajan CMaharajan C
Hey,

No, you cannot achieve this in a single trigger. Salesforce does not support this feature, so you have to create a trigger for each object.

Thanks,
Maharajan.C