SFDC Stop - Always the latest about Salesforce


Full Tutorial Series with videos, free apps, live sessions, salesforce consulting and much more.


Telegram logo   Join our Telegram Channel

Tuesday, 30 June 2020

Extract Update and Deploy Metadata to Salesforce Org | SFDX Deploy Tool | Deploy Extracted Metadata

Hello Trailblazers,

In this tutorial, we're going to learn how we can very easily extract, update and then deploy metadata to a Salesforce Org by executing a single command from SFDX Deploy Tool for Windows.

Use Case:- In real life projects, when we're actually working in Salesforce, it usually happens that we need to deploy some metadata from one Salesforce Environment to another, let's say you've completed a feature in developer environment and you need to push all the changes to a QA sandbox, while pushing the changes it usually happens that we face some deployment issues, and we need to update some metadata and then try to deploy again and again. This can be very hectic specifically if you're using change sets which take time to upload and then you need to wait for it to be available in the destination org where you want to deploy.

We'll learn how we can make those deployments very easy using SFDX Deploy Tool for Windows

SFDX Deploy Tool can be downloaded from the github repository here:- https://github.com/rahulmalhotra/SFDX-Deploy-Tool

For this tutorial, we need SFDX Deploy Tool to be already setup with you. If you want to know more about how to setup SFDX Deploy Tool, have a look at the README file of the GitHub repository or have a look at this blog post or the tutorial below:-


Once you've setup SFDX Deploy Tool, i.e. the source and destination orgs, where you have to pull and push the metadata respectively. You can open the tool and you'll see the below screen:-


As you can see in the above image, I have updated this tool and added 3 more options at number:- 2, 5 and 6. These options are:-
  • Extract fetched metadata at option 2
  • Validate extracted metadata in destination org at opton 5
  • Deploy extracted metadata in destination org at option 6

Once you've setup the tool, the first step you need to do is to fetch the metadata from the source org. That you can do by setting up the package.xml present under the metadata folder. After you have the package.xml ready, open the deploy tool, choose option 1 and press the Enter key. A sample package.xml is shown below:-


Once you've fetched the metadata from the source org, you'll see an unpackaged.zip file automatically created in the base folder as shown in the above image. This zip file mainly consists of all the metadata that you've fetched using the package.xml. Our next step is to extract and update this metadata before deploying it to the destination org.

To extract the metadata, open SFDX Deploy Tool and choose option 2 with the name:- Extract fetched metadata this option will extract the fetched metadata using windows powershell, once the metadata is successfully extracted, you'll see an output as shown below:-


In the base folder, you can see that the unpackaged.zip file is extracted automatically and a new folder named unpackaged is created which consist of all the metadata that we fetched from the source org as shown below:-



In case you don't have powershell in your windows you can use any other tool to extract that zip file. Now, we can simply open any metadata and update it. Once, we've updated the metadata, it's time to validate and deploy the extracted metadata.

To Validate Extracted Metadata:- Open SFDX Deploy Tool and choose option 5 with the name:- Validate extracted metadata in destination org

To Deploy Extracted Metadata:- Open SFDX Deploy Tool and choose option 6 with the name:- Deploy extracted metadata in destination org. This option will automatically pick the updated files in the extracted folder and deploy them to your destination org.

If you face errors while deployment, you can simply update the extracted files in VSCode and use SFDX Deploy Tool to deploy the metadata again and again in a single command.

Tired of reading or just scrolled down ? Don't worry, you can watch the video too:-



That's all for this tutorial everyone. I hope you liked it, give a try to SFDX Deploy Tool and let me know your feedback in the comments down below.

Happy Trailblazing..!!

Sunday, 28 June 2020

Salesforce Git Codelab | Learn By Doing | Live Deployment | SFDC Stop | GitHub Actions

Hello Trailblazers,

Good News :-) We recently crossed 2500 subscribers on YouTube...!! Thank you for being supportive all the time, you have made it possible.

To celebrate this, I am very excited to present the first CodeLab from SFDC Stop:- "Salesforce Git CodeLab" where you'll learn about the concepts of git by actually coding yourself and finally, you'll be having your name in the SFDC Stop Contributors after completing the code lab.

The Salesforce Git Codelab will be live today i.e. 28th of June 2020 at 7 P.M. IST on SFDC Stop YouTube Channel. and I'll be available on the live chat to answer any questions that you have during the premiere.

So, make sure to set a reminder for the premiere by clicking on the below video or subscribe to the channel to get notified



See you soon...!!

All the instructions regarding the codelab are also available in the README file of the GitHub Repository that you can follow in order to complete it. Have a look at the GitHub repository by clicking here.

Happy Trailblazing..!!

Sunday, 7 June 2020

How to connect VSCode Salesforce Project to GitHub ? | Getting Started with Version Control System

Hello Trailblazers,

In this post, we're going to learn how we can connect VSCode Saleforce Project to GitHub. We're going to create a new GitHub repository, commit our changes and push it to our GitHub repository. Let's Begin.

Download Git

The first step is to download and install git in your system. In order to download git, go to this link:-  https://git-scm.com/downloads and you'll see the below screen.


Git is available for Mac, Windows and Linux. Download by clicking on the button as shown in the above image and follow simple steps to install git in your system.

Initialize git in VSCode

Now, as you've installed git in your system, move on to your Salesforce Project in VSCode and click on Initialize Repository button available on the 3rd section in the left side bar as shown below:-


As you click on this button, it will automatically initialize the repository for you as shown below:-


If you want to initialize repository using command, you can just open terminal and write git init and press enter in order to initialize a new repository in the project folder. You can see in the above image, in the left sidebar, we're having all the files with an indicaton U where U means Untracked i.e. these files are currently not being tracked by git.

Commiting the files

Just to give you a brief overview:-  Git is a version control system which basically tracks all the changes that you're doing. Any new file that you create is initially Untracked. Each file in a git repository can be in one of the below state:-

1. Untracked:- When a new file is created by the user, it is untracked or we can say that this file is unknown to git.

2. Tracked / Index Added:- When we specify or tell git that this is a newly created file and you've to track this file (particularly known as staging the file), the status of the file is changed to tracked or we can say that a particular index (number) is given to the file so that it can be identified by git.

3. Committed:- When we're done with the required changes, we commit that file. Git mark that file as committed and add an entry in  it's internal changelog which has the required updates with a Commit Message.

4. Untracked / Modified:- When a previously commited file is updated, the status of the file is changed to untracked / modified. We need to stage this file again to tell git that this file is ready to be committed.

5. Tracked / Index Modified:- When a modified file is staged by the user, it's status is again changed to tracked. At this point the index of the file is modified with recent changes and the file is again ready to be committed.

The basic flow for new files will be:-

Untracked -> Index Added (Tracked) -> Committed

and for existing files that are committed before, the flow will be:-

Untracked -> Index Modified (Tracked) -> Committed

So, we've just initialized a git repository and all our files are untracked by default. The next step is to stage the files. This basically tells git that these are the files in which the changes are completed and these files are now ready to be committed.

You can manually stage each file one by one or only some of the files by clicking on the + icon after that file name as shown below:-


Once you've marked even a single file as staged, you can see the staged files under the Staged Changes heading and unstaged files under the Changes heading in VSCode as shown below:-


If you want to stage all the files at once, click on the + icon on the Changes heading as shown below:-


Once all your files are staged, the next step is to commit these files. In order to commit the files you need to specify a Commit Message. As you can see in the below image, you can specify a Commit Message in the message box in VSCode and click on the right (tick) icon to make a commit.


As you can see in the above image, I have specified a commit message as Initial Commit as it's the first time I am committing all the changes to git. You can give any commit message of your choice. Once you've committed all the files, your git changes sidebar will become empty as there is no further change made by you after the last commit.


After committing, if you do even a single change, your git bar will show you that file as Modified and you need to stage and commit that file again to mark the change as done.


As you can see in the above image, I have removed opening brace { from my setRequestMap() method and as I saved this file, it's specified as modified by the git in sidebar. After I am done with all the changes, I need to follow the same procedure as we did above to stage and commit the file. You can click on the filename in the git sidebar to review the change you've done as shown below:-


You can revert one or all the changes by clicking on the Undo icon which says (Discard Changes), on the left of the + icon for single file as shown in the above image or it'll show Discard All Changes if you see on the Changes heading.

Creating a GitHub repository

Now, we've done our first commit locally, it's time to create a new GitHub repository and push our changes here. To do that, first create an account on https://github.com/ 

After you created an account and you're logged in on github, the next step is to create a new repository. Go to the top menu bar and click on the + icon there and choose New repository as shown below:-


You'll see a new page as shown below:-


As you can see in the above image, first of  all you need to add a repository name, then you can give a description of your choice. After that you need to specify if your repository is public or private.

Public Repository:- Visible to everyone. Anyone can have a look at the code, clone your repository or submit a pull request.

Private Repository:- Visible only to you and the collaborators. You can invite people to collaborate on a private repository on github and they'll have access to this repository.

We don't need to initialize  this repository with a README as our project in VSCode already has a readme file as shown in the below image, so keep it unchecked.


Click on the Create Repository button to create a new repository as shown below:-


Once a new repository is created you'll be taken to a new screen as you can see in the below image:-


As you can see in the above image, I have a HTTPS URL automatically generated which is:- https://github.com/rahulmalhotra/ci-cd-tutorial.git

Adding origin to local repository in VSCode

Our next step is to tell VSCode git repository that it has to push the changes to this repository URL that we got from GitHub. So, we need to specify a remote server by giving this URL to our local git repo. In order to do that, open the terminal in your VSCode and execute the below command:-

git remote add origin <YOUR-REPOSITORY-URL>

As you can see in the below image, I have given my repo URL that I got from github after the git remote add origin command. This will basically tell my local git that this is the remote origin (server url with the name or alias origin) where I am going to push my code. You can also run a git remote -v  command to verify the remote URLs as shown below:-


I have also executed git status command to check the status and make sure that everything is clean and ready to be pushed.

Pushing our changes to GitHub

To push your changes, you need to execute the git push command from your terminal as shown below:-


As you can see above, as I executed git push I got a message that this branch has no upstream branch set. This message basically means that we haven't mapped our local git branch to the git branch on github server. By default, when you create a new git repo. You have a master branch automatically created. Similarly, on github when we created a new repository, a master branch is automatically created. But our next task is to tell git that you need to push our code in the local master branch to the remote master branch on github. In order to do that execute the command as specified by git in the above image which is:-

git push --set-upstream origin master

The above command will tell git to set the upstream (remote) branch as master for the current local branch which is also master by default and push the code. The shortcut for the above command is git push -u origin master where -u stands for --set-upstream


As you can see above, as I executed this command, the command asked for my github username and password that I entered and everything is pushed onto my github repository and I got a message that Branch master set up to track remote branch master from origin.

If you now go to your github repository and refresh that page, you can see that the code is pushed and is available on your github repository as shown below:-



Note:- Any empty folders in your project are automatically not tracked by git and will not be pushed to your github repository as well.

You can also push to your github repository by using the push option in VSCode as shown below, but make sure that you've set the remote origin first which is a one time effort that we did above.


Now it's your time. Make some changes, commit them and push them again to GitHub. Explore your commits in the GitHub repository and see what information you can see from there. You can have a look at the CI/CD Tutorial github repository that I used in this tutorial by clicking here.

Tired of reading or just scrolled down, don't worry, you can watch the video too.


That's all for this tutorial everyone, If you liked it, make sure to share it in your network and let me know your feedback in the comments down below.

Happy Trailblazing..!!

Saturday, 30 May 2020

Getting Started with Scratch Orgs | DevHub | Link VSCode project to a New Scratch Org

Hello Trailblazers,

In this post we're going to learn how we can enable devhub to create a scratch org and we'll also create a new VSCode project and link it with scratch org. Let's begin.

Enabling DevHub

In order to enable DevHub in your developer edition / trial / production org / business org, follow the below steps:-

1. Login as a System Administrator

2. Go to Setup and search for DevHub

3. You'll see a screen as shown below:-