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 

Trigger on Custom Setting

We're interested in updating records when the value of a Custom Setting changes.  I was wondering if anyone knows if you can fire a trigger on update for a Custom Setting value?  There does not seem to be anyway of programatically inserting or updating the information held,  so,  a trigger appears to be the only option of automating the updates.




Its not possible to write a trigger on the Custom Settings.


Though you are able to write a trigger on Custom will not be able to Update the Records as Custom Settings do not have the Lookup Fields to associate your Custom Setting with any of the Objects(be it Standard or Custom).


So if you are trying to write a trigger on the "Custom Setting" and update the object related with the custom settings then its not possible.




Karimov CeyhunKarimov Ceyhun



Doesnt it seem weird? the user can update or delete custom settings without any trouble and program can crash. Is there another through apex code without triggers?




Ceyhun Karimov

Bit of work to start with, but perhaps you could define a separate custom object that has an after trigger that copies all validated content across to the custom settings. That way, you get to leverage the standard validation and triggers available for regular objects and only pass through the validated results to update the custom settings. A drawback with this method is you can't update the custom object contents if someone chooses to update the custom settings directly. If your regular users don't have access to settings then I guess it might work. Or you can just use a custom object instead of custom settings and say goodbye to the SOQL-free access and performance benefit...