This article is part of a group of articles around devOps Center. If you didin’t read it, please check it to make sure you have all the prerequisites in term of installation, pipeline configuration…:
- Setup devOps center: activate, install and assign permissions
- Link your devOps center to Github, build your devOps center pipeline
- Start working with work items and deploy through the pipeline (this article)
Now we will create things to migrate and proceed to see how it works.
Create a feature to migrate
For this tutorial, I’ll do 2 things:
- Implement a simple record triggered flow (that does nothing really interesting 🙂 ) Name: Change title / Flow API Name: Change_title
- Add a new field on the Opportunity standard object: Updated_Title__c
Create a work item in the devOps center
Now, I want to migrate those changes to the UAT org and then PROD through the Pipeline I created before.
For that, I create a Work item by clicking on the left on “Work Items” and then on the “New Work Item” button on the right.
![Create a new Work Item in the devOps center](https://www.black-fox.org/wp-content/uploads/2022/12/image-5-1024x401.png)
This work item will represent a part of the work I want to push until production.
For that, I recommand the granularity of a bug / user story, something that can be related to a ticket you or your team work on.
So, give the work item a relevant title. If you’re using a bug tracker or issue tracker like JIRA, you can also add a reference to the ID of the ticket it is related to in the Title. That’s good for tracability!
Click on save to create you work item.
Configure your work item
![Choose if you add manually metadatas or if Salesforce devOps center will do it](https://www.black-fox.org/wp-content/uploads/2022/12/image-6-1024x259.png)
Now click on your work item. That will open a screen like the one on the above picture.
Our objective will be to:
- Compose this work item of things we want to migrate: the flow and the custom field
- Deploy thos changes to the other Sandboxes: UAT and then production
To compose a work item, as suggested by the two checkboxes, you have two options:
- First: Retrieve manualy the changes and commit them to Git (see my other article on how to retrieve changes)
- Second: Let Salesforce do that for you: work on an org, identify changes and add them to Git
For this tuto, I’ll choose the 2nd option: let the Salesforce devOps center auto detect the changes I’ve done in my Sandbox.
To go further, click on the proceed button.
Compose the work item with metadatas
Now we are going to add metadatas, configuration to migrate to our work item.
Remember that I previously added:
- A custom field to the Opportunity standard object
- A flow
![Pull and browse changes in the Salesforce Sandbox](https://www.black-fox.org/wp-content/uploads/2022/12/image-8-1024x479.png)
Click on the “Changes” tab and on the “Pull changes” to retrieve the metadatas on the development Sandbox.
This will retrieve all the modified metadatas.
![Identify the changes in the Salesforce dev Sandbox](https://www.black-fox.org/wp-content/uploads/2022/12/image-9-1024x311.png)
In the above example, I have selected the two elements I have selected: the flow and the custom field.
In order to validate the retrieve of the 2 elements, I add a comment. This comment will be added as the Git commit message:
![Add a comment to commit the retrieved metadatas to Git](https://www.black-fox.org/wp-content/uploads/2022/12/image-10-1024x215.png)
If we go to Github, we can see that the branch corresponding to the Work item have been pushed to Github:
![Salesforce devOps center have created a pull request](https://www.black-fox.org/wp-content/uploads/2022/12/image-11-1024x259.png)
Imagine you’ve forgot something, like a profile a permission set or a Layout (we can see that for example the Layouts of the Opportunity object have been modified when I added a new field)
You can select it and commit it on top of what you have retrieved/commited before.
Create review: Validate the build of your work item
When you have retrieved every element to build the work item by adding every modification you want to bring to the production, it’s time to create the review.
Click on the “Create Review” button
![Create a review for your work item](https://www.black-fox.org/wp-content/uploads/2022/12/image-12-1024x415.png)
If we go to Github, we can see that clicking on “Create Review” have automatically created a pull request corresponding to the work item:
![In Github a pull request have been created by the Salesforce devOps center](https://www.black-fox.org/wp-content/uploads/2022/12/image-13-1024x236.png)
Let’s open the pull request and check that everything runs as expected.
We can see that the commit I’ve added is present:
![Inspect the pull request created by devOps center](https://www.black-fox.org/wp-content/uploads/2022/12/image-14-1024x378.png)
More important, let’s go to the “Files changed” tab to inspect the metadatas we are going to merge into the uat branch.
And… tadaaaaa !
As we can see below, the pull request contains 2 things: the flow and the Custom field on the Opportunity object.
![Verify the Salesforce metadatas in the pull request](https://www.black-fox.org/wp-content/uploads/2022/12/image-15-1024x480.png)
Validate the work item in the devOps center
Everything is ok? You succedded to add everything to you work item? Everything was present as expected in the Pull Request in Github?
You did a great job!
So, to validate, click on “Ready to promote”:
![Mark the work item as "Ready to promote"](https://www.black-fox.org/wp-content/uploads/2022/12/image-16-1024x532.png)
Promote the work item to the next Sandbox
Push work item to the next stage
Now the work item is ready to promote, and so, to be deployed on the next stage Sandbox.
So, to promote the work item, click on “pipeline” in the left toolbar.
![Go to the devOps center pipeline](https://www.black-fox.org/wp-content/uploads/2022/12/image-17-1024x319.png)
Select the work item you want to promote and click on the “Promote Selected” button that appeared to deploy the selected work item to the UAT environment (you may have to enter your credentials)
![Select the work items to be promoted to the next Sandbox](https://www.black-fox.org/wp-content/uploads/2022/12/image-18.png)
After clicking, on “Promote Selected”, the “Promotion Options” window appears:
![Configure the deployment of the work item](https://www.black-fox.org/wp-content/uploads/2022/12/image-19-1024x529.png)
Here you can configure your deployment options.
Changes to promote:
- First option: only the new metadatas will be deployed to the target Sandbox. This is the recommended option by Salesforce, since it will deploy only a few metadatas
- Second option: All the metadatas in the branch (inluding some that may already be deployed on the target sandbox) will be deployed. It might take some time to deploy. It’s not the Salesforce recommended option.
Test Options are the Apex unit test that you want to run after the deploy. Chose the one that fits to you.
Click on the “Promote” button to promote your work item to the UAT Sandbox.
![The work item have been successfully promoted](https://www.black-fox.org/wp-content/uploads/2022/12/image-20-1024x461.png)
After the work item have been promoted, it comes to the UAT column, ready to be promoted to the next stage!
Verify the Work item promote worked correctly
Now, let’s check what happened behind the scene…
On Github:
We can see that the Pull Request we checked before is now merged and closed:
![The pull request have been merged](https://www.black-fox.org/wp-content/uploads/2022/12/image-21-1024x147.png)
And we can see that a new Pull Request, waiting for promotion to PROD have been created and is openned:
![A new pull request have been created](https://www.black-fox.org/wp-content/uploads/2022/12/image-22-1024x237.png)
What about the metadatas?
It’s ok for the Flow:
![The flow have been deployed correctly!](https://www.black-fox.org/wp-content/uploads/2022/12/image-23-1024x160.png)
And it’s ok for the custom field on the opportunity object!
![The custom field have also been deployed correctly](https://www.black-fox.org/wp-content/uploads/2022/12/image-24-1024x83.png)