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
Showing posts with label SalesforceDX. Show all posts
Showing posts with label SalesforceDX. Show all posts

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..!!

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:-

Enable DevHub

Toggle the button which says Enable Dev Hub to enable the dev hub (Please note that you cannot disable a DevHub once you've enabled it in your org).

Once you've enabled the devhub, you'll have some objects automatically visible in your org like:- Active Scratch Orgs, Scratch Org Infos etc.

Active Scratch Org object basically consist of information about all the scratch orgs that are currently Active.

Scratch Org Info object consist of information about all scratch orgs that you created using this DevHub no matter whether they're currently active or expired. It basically have the metadata of your scratch orgs like:- Edition, Created Date, Expiration Date, Status etc.

When you've enabled DevHub, you can just refresh the page once and search for Active Scratch Orgs in the app launcher. You can open Active Scratch Orgs as shown below:-

Active Scratch Orgs

It is currently empty because we haven't created any scratch org yet. Let's create a new scratch org, but before that, we need to create a new VSCode Project.

Create a new VSCode Project

Go to your VSCode and create a new project like we did in our How to setup Visual Studio Code for Salesforce tutorial. This time you can select Create Project instead of Create Project with Manifest opton as we don't need a manifest while working with Scratch Orgs as shown below:-


You can use the standard template itself


and add a project name you like to create a new project. I am using ScratchOrg1 here.


Once you've created a new project. The next step is to Authorize Our DevHub. So, let's see how we can do that.

Authorize DevHub

In order to authorize DevHub, open a terminal in VSCode and enter the below command:-

sfdx force:auth:web:login -d -a <Alias of your DevHub>

In the above command,

-d is used to specify Default Dev Hub. We're setting this DevHub as the default devhub for scratch org creation in future

-a is used to specify the Alias of your DevHub. An alias is nothing but friendly name for your devhub. Like in the below screenshot you can see that I am setting my devhub alias as CuriousFoxDevHub so that in future I can simply refer to this org using the alias I have given.


Once you press Enter, It'll automatically open your browser where you can login and it'll ask you for permissions after logging in as shown below:-


Click on Allow. You've now successfully authorized your DevHub and you'll see the below message in your CLI:-

  

Create a New Scratch Org

Now we need to create a new scratch org. As we've already created a new VSCode project. Inside that project only, open the command palette and type Create a Default Scratch Org as shown below:-


When you choose Create a Default Scratch Org, it automatically creates a scratch org for the current project you're working on. Choose this option and you'll see another option where you need to select the scratch org definition file as given below:-


Select the default scratch org definition file which is already created for you unless you want some extra features automatically enabled in your scratch org like:- MultiCurrency, Person Accounts etc. The default config file is stored in the config folder as shown below:-


You can add a number of features as shown above, to learn more about the scratch org definiton file, click here

Once you've selected a definition file, you need to enter an alias for your scratch org as shown below:-


SFDC Stop Tip:- Give the same alias as the name of your project so that you remember it easily. I am giving the same alias here i.e. ScratchOrg1

Next, you need to specify the number of days between 1-30 for which your scratch org is active as shown below:-


Press Enter and your scratch org will be created automatically using the default DevHub that we set before. You can open the sfdx-config.json file where you can see the defaultdevhubusername as well as the defaultusername of your org which is linked with the current project as shown below:-


Once your scratch org is created, you can open that by opening the command palette and writing the command:- Open Default Org and pressing Enter as shown below:-


This command will automatically open your newly created Scratch Org in your browser. You can also go to your DevHub where you can see a new record under the Active Scratch Orgs section as shown below:-


Congratulations..!! You've created a New Scratch Org Succesfully and linked it with VSCode.

Now it's your turn, create a new scratch org and try updating data in Scratch Org and pull it down in VSCode. Also, create a new Apex Class or any other stuff in VSCode and push it into your scratch org.

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.

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


Happy Trailblazing..!!