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
mjohnson-TICmjohnson-TIC 

Trigger event based off schema change?

Does anyone have a way to trigger an event (call apex code) when the schema of an object changes (such as a new field being added)? The only way I can come up with, is scheduling an apex job to perform desired actions based on metadata timestamps on objects (createddate modifieddate etc). Does anyone use or can anyone come up with a more realtime way to do this?
Sonam_SFDCSonam_SFDC
I was thinking if its possible to use Describe calls (describesobject(): https://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_describesobject.htm) to get the list of fields on the object store in a list -

You can then compare the size of the list to see if there is a new addition to the list anfd then process the required event
mjohnson-TICmjohnson-TIC
Thanks, that's what my scheduled apex code is doing. I am trying to figure out a way to trigger the action on change of the object as opposed to looking for changes on a schedule.
Sonam_SFDCSonam_SFDC
aah.got it...AFAIK, trigger can accept on DML events on the Object at the record level but not at the metadata level..