Is it possible for the trigger to see the name of the object it's firing for? Say can I make the OpportunityTrigger be aware that the object name it's firing for is Opportunity
without hardcoding the object name in the code?
EDIT
I want to use Custom Metadata to make Object_To_Track_mdt
. Once a trigger fires I want to use the object name the trigger is firing for to see if the object needs to be tracked or not. Here's a very rough code sample I have in mind:
Object_To_Track__mdt trackedObject = [
SELECT Id,
(SELECT Id FROM Fields_To_Track__r)
FROM Object_To_Track__mdt
WHERE DeveloperName='Lead'
];
if (trackedObject != null && trackedObject.Fields_To_Track__r.size() > 0) {
// Verify if the modified fields for Lead need to be tracked or not.
}