Why Do We Use a Repository with Salesforce?
We all want a product with our Salesforce CRM that can provide us with better accessibility and experience to our development modules and releases. If you are still struggling to find something that can give you precisely what you need and much more, then I am sure you haven’t heard of an online repository.
What is an online repository?
In layman’s terms, an online repository is like a layer between your Salesforce CRM domain and the database or sandboxes, making your accessibility better and improving the experience of your development modules and releases.
Let me tell you some fantastic features of an online repository.
Why should one use it?
- Works as an online backup for your whole CRM.
- Multiple users can work on their respective scratch orgs without interfering with the other user’s progress.
- Better Data Security.
- Makes the process efficient and smooth.
- Productivity booster.
- More Reactive.
- Restoration and backup of data have never been easier.
The best part is it’s almost effortless to use a repository, and you only need to install four software in your local system
- Salesforce CLI
- Extension packs for VScode, Salesforce Salesforce, and a package generator.
Salesforce and Online Repository Integration
After you have installed all the four software mentioned above, you need to complete five steps-
- Open gitbash in your system and set the hostname by running the command git config -global user.name “Your Name”
- Set up the email by running the command – git config –global user.email “Your Email”.
- Now open Vscode and terminal to generate the SSH key by running the command ssh-keygen -t rsa -b 4096 -C “Your Email”
- Rash the destination folder to access generated key.
- The SHH key is stored in the PUB file in the folder
We have completed our setup process, and now it’s time to start using the online repository. There are many online repositories like GitHub, GitLab, Bitbucket etc. where you can find this but I will show you an example using Bitbucket.
- First, you must create an account in Bitbucket; if you already have one, log in.
- Create a project and a repository after that
- Now add the ssh key, which was generated earlier.
- Go to your setting by clicking on your user icon
- For adding an SSH key go to settings- SSH keys and click add key.
- Now paste the generated SSH key there and click add; you’ll receive a confirmation email once done.
- Go to the created repository and click on the clone icon and select SHH there, as shown in the image below:-
- Now you have to copy and paste the command in the terminal of the vs code.
- After a few moments, your repository will be successfully cloned in your system
- Now in vscode, go to Files -> Open Folder -> ‘Folder that you just cloned from repository’.
- Wait for some time for the extension to work correctly, press Ctrl + Shift + P, and select SFDX: Authorize an Org.
- Now enter an alias for your org by selecting the production
- Now we have to log in to production and run a command in the terminal section sfdx:force:source: pull -f this will pull all the data from your production org.
- After this, you must create a branch in Vscode named after your production and treat it as a main or the primary branch.
- Commit all the staged changes available there and commit all the changes to the branch.
After following all the steps, we will have a complete backup of our project on Bitbucket and make changes to the branch for every production release.
One of the features of the online repository is that it supports multiple-user access. Still, sometimes when multiple users push their progress to the same branch you are working on, it increases the chances of data loss, so to prevent this from happening, we should have our users working on different scratch orgs. It will provide a better understanding and environment for growth.
- Enable dev hub in production org as shown in the below image:-
- Create a scratch org by Pressing CTRL + SHIFT + P, and selecting SFDX: Authorize a dev hub
- Now login with your production credentials and press CTRL+SHIFT + P again and select SFDX: Create a default scratch org
- Fix the lifespan of your scratch org and its alias.
- After successfully creating a scratch org, we will change the default org in Vscode again by pressing CTRL+SHIFT+P and selecting SFDX: Set a Default org and select your org.
- Now we will refresh all the changes from production in the local environment of vscode
- Now to deploy all the components to your scratch org run the command sfdx:force:source:push -f
- You can easily make more functions and stages and commit changes to the branch above.
Other Things to Keep in Mind:-
- To create a new scratch org and new branch for every new task.
- Pull down the latest code and push it to the scratch org daily to save your data from merge conflicts while deploying. If you are working on the same scratch org everyday
- After committing the required changes to the branch, we need to merge the branch to the intermediate layer of sandbox between production (QA or UAT). Raise a merge or pull request to that desired branch from your current branch.
But when we merge code, we still need to deploy changes to the desired org, and to save time and effort, we will use CI/CD.
CI/CD(Continuous Integration / Continuous Deployment) can be beneficial while working on our project because when we merge our code to the desired branch, CI/CD will automatically start the deployment of the desired changes to the specific environment and it has some other benefits too like:-
- Faster Release Rate
- More Testing of the data
- Customer Satisfaction
- Fully Transparent and Accountable
- Easily Maintained
- Streamline the Deployment of your progress
And the best part is it’s not rocket science to implement CI/CD; you can quickly boost your CRM’s productivity by implementing it under the guidance of any tech leads or architects.
At Manras, we have always prioritized communal growth and our heart smiles when we see the community grow and the world prospers. Feel free to reach out to us at email@example.com, we are readily available to answer all your questions and walk you through all operations challenges that come your way.