I have a requirement where I need to send an email notification to specific set of users whenever a Visualforce Page gets updated. Is there any way to achieve this functionality ? Any pointers for this will be really helpful.

  • 1
    Who are the Users in this context? I wouldn't think that any Business/End Users would need to be notified for any such change but System Admin. Is that what you are looking for?
    – Jayant Das
    Jul 3, 2018 at 14:55
  • 1
    You could do this, by doing something funky with a scheduled job, and checking against versioned metadata using the metadata api (or checking for changes in a period). Before trying something like that, I'd look internally at your developer processes & deploy patterns. Are you not being told when/if deploys are happening? Are your developers not providing patch notes or other documents of changes? These are people problems that are best dealt with internally, instead of trying to bend a system around the need. Some extra details in your post about the situation could help here. Jul 3, 2018 at 15:02
  • @JayantDas This is not a business requirement and is a requirement of our Release Management team. So you can consider the set of users a System Admin. But, I don't think here type of users is an issue.
    – user40401
    Jul 3, 2018 at 15:07
  • @battery.cord : This is an internal requirement for our Release Management team, where they need a notification whenever a visualforce page gets deployed in Sandbox.
    – user40401
    Jul 3, 2018 at 15:11
  • Thats just repeating what you said in your question. Look past the surface of the problem - why do they need to know? Why isn't this communication happening? Why just visualforce pages? Why not classes or the controller behind them? What does this do that the standard UI or package management not do? To me this question is kind of a "Code smell" - you could do it a certain way, but it feels like a bandaid, covering up something that is the real problem. I'd rather deal with the real issue, even if its a lot tougher than writing a few lines of code. Jul 3, 2018 at 15:19

1 Answer 1


As battery.cord said in the comment, you can check for the last modified date on your pages and report any changes. Generically, it might look like this:

public class CheckPageUpdates implements Schedulable {
  public void execute(SchedulableContext context) {
    LastTimeChecked__c check = LastTimeChecked__c.getOrgDefaults();
    if(check != null) {
      check = new LastTimeChecked__c(LastCheckedDateTime__c=DateTime.now());
    ApexPage[] pagesModified = [SELECT Name FROM ApexPage WHERE LastModifiedDate <= :check.LastCheckedDateTime__c];
    if(!pagesModified.isEmpty()) {
      // Send an email or something here
    check.LastCheckedDateTime__c = DateTime.now();
    upsert check;

You can schedule this for whatever frequency you like, such as hourly:

System.schedule('MonitorVFChanges', '0 0 * * * ?', new CheckPageUpdates());

Edit, based on additional comment: For controlled Sandboxes, like UAT/QA/etc, you should still generally have a controlled deployment system. This prevents developers from accidentally overwriting each others' code. At minimum, consider using a repository to make sure that conflicts are caught before they end up in the Sandbox.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .