Our Version Service API allows you to create versions of projects that contain a record of how a project has progressed. With project versions, you can compare previous and current details.
However, creating project versions isn't really something that comes to mind when you’re busy managing projects. Fortunately, we have good news: you can easily schedule a job to create project versions periodically using the Apex Scheduler and our API.
Sample Scenario: Project Versions Created Monthly
Using the Apex Scheduler you can schedule a job that runs once a month. Knowing this, you can have the job call a class with a method that calls our API and creates a project version.
- Add a custom checkbox field to project named ‘Versioning__c’, which allows you to decide which projects get versioned each month and which don’t. We will use this field to query for Projects that we should create versions of.
- Create global class that implements the Schedulable interface and have it call our Version Service API:
Now all we have to do is call the Apex Scheduler to schedule our job. Reminder: Make sure you have the correct permission controls set up for your selected projects to allow versioning.
This can be done in two ways:
Execute Anonymous Apex
We use a CRON expression to state when we want our job to run. Here we have it set to run on the first of every month.
Schedule from UI
- From Setup, enter Apex in the Quick Find box, then select Apex Classes.
- Click Schedule Apex.
- For the job name, enter ‘Monthly Versioning’.
- Click the lookup button next to Apex class and enter ‘ScheduleVersioning’ for the search term and click the name of your scheduled class.
- Select ‘Monthly on day 1’ for the frequency, your preferred start and date dates, and ‘00:00’ for you preferred start time.
- Click Save.
If you look at Scheduled Jobs in setup, you can see the job we scheduled and the next time it is set to run.With this implementation your projects are continually versioned even after being completed or set to inactive. You have to uncheck the ‘Versioning’ checkbox or set some sort of workflow validation rule that unchecks‘Versioning’ when a project reaches completion or is set to inactive. Notifications
It is already hard enough to remember your daily schedule, and you don’t need to add on a monthly task on top of that to check on. Good thing our API allows an easy way to send notifications and reminders.
- Head over to Setup, enter ‘Custom Settings’ in the Quick Find box and select it.
- Find and click Project Versioning Settings.
- Click Manage.
- Depending on if you want to set an org-wide default or a profile specific default click the top or bottom ‘New’ button respectively. For this example, we are selecting the top button for an org-wide default.
- Enter your email address(es) in ‘Notifications_Recipients’ as a semicolon(;) separated list.
- You can choose to receive notifications through chatter, email, or in the form of tasks. For this example, we select ‘Notifications Email’.
- Click Save.
Now you’ll receive emails every month after your project versions have successfully been created.
Notifications also include job failures and version deletions.
Simple enough right? Now all we have to do is test your Apex code: