Our Version Service API allows you to create versions of Projects. It’s important to have Project versions. It helps maintain a record of how a Project has progressed and allows you to look back on previous details or past versions of a Project. However, creating project versions isn't really something that comes to mind when you’re busy managing projects. For example, let’s say you want to know what a project looked like when it moved from phase 1 to phase 2. Fortunately, there is good news: we can use the Process Builder and an invocable method to automatically call our API and create a version of the Project.
Sample Scenario: Project Versions on Approved Milestones
When a Milestone is approved, it usually signifies an important or big step for a Project. This marks a good point for when Project versions should be created. You can do this by using the Process Builder on Milestone whenever its status is changed to ‘Approved’.
- Create an Apex class with a invocable method that calls our Version Service API:
Along with the date in the version name, the notes tell us which milestone triggered the version to be created.
- Create a new Process with the Process Builder and select ‘A record changes’ for ‘The process starts when’.
- Add the ‘Milestone’ object we are working on and select ‘When a record is created or edited’.
- Add criteria for our following action. Select ‘Conditions are met’ and ‘All of the conditions are met’. For the Set Conditions, add:
Status Equals Picklist Approved
Status Is changed Boolean True
Note: you could change the implementation to also create versions when approved milestones are inserted.
- Finally, create an action and set the type to ‘Apex’ and the class to our invocable method name. For the Apex Variable, we select our ‘milestone’ field and set it to our Milestone object
- Now let’s activate our process and see it in action.
If an error occurs from versioning, the process builder states that the flow failed to trigger instead of the Version Service error message. Alternative means to communicate errors (update a field on the record, set a status, required permission controls, etc…) should be explored if the standard platform error handling in process builder is not acceptable to your users.
Next, If we go to our project page we can see its milestones:
Reminder: make sure the user has the correct permission controls set up to allow versioning.
Let’s change ‘Milestone1’ to ‘Approved’
Now if we look at ‘Managed Versions’ on our Project page, we can see our newly created Project version.
Clicking it takes us to the version detail page.
And in the related tab are all the Version’s related objects.
Now let's look at a unit tests for our code: