Declarative Scheduler Tool

Credit – I need to give ample credit and then some more to Doug Ayers. The original version was inspired by some of his work and then in version 2 it is literally copied off his work. His schedule adding campaign members is built into the tool

Sample user cases

  • A report of all leads over 4 days that have been stuck on a status for 4 days
  • Create a task to follow up on all opportunities that have a closed date in the past and no follow up tasks and haven’t been modified in the last 7 days
  • Send an email on a contacts birthday
  • Process mass updates to all data (create a workflow to fire when the triggering field change and then to do the function you want)
  • Delay bulk workflow actions into a nightly job
  • Backdate workflow processing – when you created a workflow/process build you can trigger it to run on all of the existing records 🙂
  • Trigger a contract to renew on a certain date or create a new opportunity
  • Let me know yours…

Notes: – It works off batch apex so you can change the batch size on each record. This stops any soql 101 or timeout process builder/flow errors – Has been tested to work on reports of up to 50,000 records. It’s built to be generic so works across all obejects – but you should add in your own datetime field.

Instructions

 

  1. Set up a report 
    1. Include an ID field of the record to update
    2. Include a datetime field that can be changed by the tool
    3. Add in report filters to limit the number of records to update
  2. Add a “Scheduled Report” record
    1. Select the record type “Update Field on Records”
    2. Select the frequency of the update. This tool will run every hour and detects if any “Scheduled Report” records are due to be updated.
    3. Look up the report in the drop down boxes at the bottom. Select the Id and datetime fields
    4. Click save –
    5. WARNING: saving the report selection schedules the tool to fire in one minutes time. If your record meets the condition then it will fire straight away. Make sure no other records are going to be scheduled at the same time.
  3. Set up a process builder to fire when the datetime field is changed:

Right click on the image to save it to your computer.

Installation

Managed Package (sandbox)

View the code on GitHub

 

Troubleshooting steps

  • Check the scheduled report logs for error messages
  • Reduce the batch size
  • Try and manually change the datetime field – might by another validation rule or flow in place causing problems
  • Leave an issue on the github page

Declarative Scheduler Tool for Salesforce admins – use the reporting engine and subscribe feature to update records in report on a daily/weekly/monthly schedule

  • Create a report with the record id in column 1 and a datetime field in column 2
  • Add the filters you like
  • Click subscribe. Then select a custom action. Then Declarative Scheduler (make sure to turn off the salesforce1 notification
  • Set up when you would like these records to update and then schedule away
  • On the scheduled time the datetime field will be updated. So set up a process builder to fire when that field changes. And voilla you have a repeating schedule.

Sample user cases

  • A report of all leads over 4 days that have been stuck on a status for 4 days
  • Create a task to follow up on all opportunities that have a closed date in the past and no follow up tasks and haven’t been modified in the last 7 days
  • Send an email on a contacts birthday
  • Process mass updates to all data (create a workflow to fire when the triggering field change and then to do the function you want)
  • Delay bulk workflow actions into a nightly job
  • Backdate workflow processing – when you created a workflow/process build you can trigger it to run on all of the existing records 🙂
  • Let me know yours…

Notes: – It works off super batch apex so you can change the batch size in custom settings. This stops any soql 101 or timeout process builder/flow errors – Has been tested to work on reports of up to 50,000 records. Don’t go larger of Salesforce CPU times out – It’s built to be generic so works across all obejects – but you should add in your own datetime field.
Todo: – Proper test classes – Instructions – Testing – Guidelines and examples

Instructions

Install the package below.
Right click on the image to save it to your computer.

Right click on the image to save it to your computer.

Right click on the image to save it to your computer.

 

View the code and download the package at GitHub

22 Replies to “Declarative Scheduler Tool”

  1. Karleen Mendoza says:

    Hello,
    Is there away to install the package in a Sandbox? We currently have Version 1.1 installed and would like to test the new version and see how it impacts current schedules.

    1. GravityLab says:

      Hi Karleen, yes you can install any package in Sandbox. That’s exactly what they are for. The version two still contains the schedule engine in version 1 it just has an additional engine and interface to make it easier to deal with multiple schedules and more frequently. The only known drawback is that it can only run reports up to 5k records and not 50k like the first version. This is a work in progress as hopefully once that is fixed there will be no limit.

      1. Rusty says:

        I’m having an issue installing in a Sandbox also. Clicking the managed package link above will only let me login through my production orgs.

      2. GravityLab says:

        Hi Rusty, you can change any managed package link to login to sandbox by changing “www.login” to “www.test” here is the sandbox link:
        https://test.salesforce.com/packaging/installPackage.apexp?p0=04t7F000004CgRo

  2. mathew says:

    Hi there,

    This is a great tool! The only issue we have found is using it on large reports. The log is not generating any issue to go off, but the timedate field is only getting updated on about half the items on the report. Is there some way to get it to work on large (1000 – 2000 items) reports?

    Cheers!

    1. GravityLab says:

      It works on reports up to 10,000 records. I suspect a validation rule or flow error is causing a problem. Firstly, change and change the datetime manually and see if it works. If you don’t hit a problem there then try and reduce the batch size down to 1 and try again.

  3. Brahma says:

    can please provide app exchange link.

    1. GravityLab says:

      It is not published on the appexchange. Click the Managed package link.

  4. Is Lightning Experience required for this to work? That’s the problem I had with Doug’s version. My client isn’t on Lightning. I need Date/Time fields to change twice a day, once in the morning and again in the evening. Use Case: Bed in a homeless shelter. Setting up a booking system. 8AM, change all “Occupied” beds to “Booked” for the same client until 6PM. At 6PM, change all Booked beds to Free.

    1. GravityLab says:

      Lightning is not required. It can update the date time field twice a day. From there you can trigger any action you need.

      1. Thanks for your quick reply. I’m going to see what happens when I try to make this work. Keeping my fingers crossed. Looks GREAT!

      2. Hey ya’ll, I have the first scheduled report working when I hit Run Now. Which is great. Now I need to be able to schedule a TIME for the scheduler to run. I put it at 8am but when I save it, it seems to revert to EVERY HOUR. Is there a place I can see that it will run at 8am every morning? That is what I need this to do.

      3. GravityLab says:

        Hi Trish,

        Please email us at support@gravitylab.nz. Also give us login access and I’ll have a look for you.

        1. Choose Your Name | My Settings | Personal | Grant Account Login Access.
        2. Set the access expiration date for GravityLab (Minimum of 1 month for technical escalations).
        3. Click Save.

  5. Robert says:

    Hi,
    I just installed the package. Where does it reside? I cannot find it in the Tabs or sidebar… or anywhere. I see that it is installed.

    1. GravityLab says:

      You will need to look in all tabs. If you are in lightning (which you should be) click on the 9 dots in the top left underneath the logo then look for “scheduled reports”

  6. Dean Par says:

    Gravity Lab

    Many Thanks!!!!

    -I’m using to create new Records monthly on Detail pages off of Accounts
    -I use a report to filter our current customers
    -Set up Report Schedule to update once per month date field on Account
    -Process Builder creates the new record (Firm User Count which is pulled from another SQL DB)
    -Button on account page then passes Account ID to report and graphs monthly changes in Users vs Contract for each Account

    Took all of 30 minutes to setup and test in Sandbox —

  7. Lee Sauer says:

    Am I correct in assuming that this app cannot be installed in Professional Edition?

    1. GravityLab says:

      No, it requires Apex to run.

  8. Nicholas Burgher says:

    Hi, I think this is an awesome tool and will no doubt be implemented into our processes. But I was having trouble with the “Add Members AND Delete Members Not in Report”. While “Add Members Only” worked perfectly, the other seemed to add 100, then jump down to 30 contacts, and then nothing else would change. Perhaps I’m not waiting long enough? The report I’m working with have 7,000 + contacts. Good thing it the Add Members only works, so that’s definitely half the battle. Let me know if I should try anything to remedy.

    1. Nicholas Burgher says:

      I changed the batch down to 1, now everytime I refresh the page, I get a different contact from my report. So it must be cycling through but also removing them everytime it refreshes. Maybe I need to try a higher batch number. Just don’t want to break the system.

      1. GravityLab says:

        What is your report on. The report shouldn’t change it. The report should be on who you want to add to the campaign not who is in the campaign.
        You can email us a screenshot of your report type and filters to info@gravitylab.nz and we can have a 5 minute look next week.

    2. GravityLab says:

      Hi Nicholas,
      If you open the Apex Jobs in the settings. There should be a batch running. If you have a low batch size you will see lots of entries. Some of which might have errors (from validation rules or process builders).
      My second idea is to reduce your report size to fewer contacts. There are known issues with large reports. Try 500 contacts (add in any filters) to reduce the report size and see if it adds the 500.

Leave a Reply