Salesforce Deployment using VS Code

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone welcome to how to Salesforce my name is vanvendra and today I will be showing you how you can deploy Salesforce components from one sandbox to another sandbox using vs code editor very quickly uh I will be listing out the things which you need to be installed on your Windows PC or a Macbook so here let me show you what things you will need to install so obviously you should have jdk latest version foreign vs code editor so in vs code editor there are some essential extensions um that you must have obviously you will be needing it more when you will be you know using git or uh gitlab or get lens anything any extra application which you will be using during your uh you know development so for that reason there are so many extensions on uh on the marketplace uh for these for this vs code but these are the uh very basic and very important ones so Salesforce extension pack comes with a lot of extension which you will uh be installing other than that there is one more very important extension that is called Salesforce package dot XML generator uh so that's it so I think uh to get started these these things should be uh very good now if you want to make sure uh if your jdk and Salesforce CLI have been installed properly or not what you need to do if you are in a Windows uh machine go to your command line application right click on it and click on run as administrator or in a Mac you can go to terminal once you open it suppose if I want to check if my Java is installed so I'll just type Java space hyphen version and for Salesforce CLI I need to type sfdx space hyphen hyphen version so this will give you the details if you get any error that command is not being identified anything like that it means you need to reinstall or maybe you need to set up your environment variables and I think those are very very common issues and you will find tons of videos how to set up environment variables on a Windows machine and how to install uh how to install this application on a Mac uh for Mac I would suggest you if you can install Homebrew application for command line on your Mac and I think from there with the help of Homebrew commands you can you can easily install pretty much everything which you will need so let me just show you how that works if you go to home brew website and this website is called brew.sh so this command will install Homebrew on your Mac and then suppose if you want to install Java for example let me uh search for brew install Java let me search here Eclipse Java uh let me check which one is correct basically you just need to find the command see blue install Java now just for checking I know on my machine uh Java is installed but let's check who I mean if this command is working fine or not see first of all it is running a command to update your Brew application you can see first of all it is updating preview and now it is uh downloading the update uh let's make it bigger see it has installed Java so you can install anything through a brew dot sh website if they have application listed on their website you will definitely find the command and you should be able to install it very straightforwardly on Mac now let's talk about how we deploy changes so I already have uh Salesforce Developer Edition org setup uh just to teach you now for example suppose if you are working on any Apex class or any custom field anything but you're working and you want to deploy those changes to some other sandbox okay now this is a developer org we will what we will do we will just sign up for another developer org real quick so go to Google and type developer Salesforce sign up foreign so this is going to let's get started so this is uh this is also Developer Edition you just consider it uh like a source sandbox from which we want to deploy components to another sandbox first of all let me show you how do you set up how do you connect this uh Arc to your vs code editor when you open vs creditor if you have installed all the extensions um you will see something like this let me just open up a new window fresh window so that I can show you from scratch so here uh all you need to do is press Ctrl shift p it will open up uh this command palette this area is called command palette from where you can run all the commands you can do it with the help of keyboard as well with the shortcut and also with the help of most obviously when you type sfdx this will list all the commands related to your Salesforce so now you need to select create project with manifest what manifest means is uh that this will include your package.xml files where you will be listing down all the components your changes whatever you need to deploy if you want to retrieve anything or need to deploy anything you will be referring to that file which will be in a manifest folder press enter click on standard and you can give it a name for example deployment tutorial I will be saving it on my desktop so now this is a this is an empty project we haven't connected anything so far and you will see it has a all the folder structures as per your Salesforce for example if you go to Force app folder you will see all the respective folders for example or our classes flexi Pages layout lighting web components objects Etc if you want to connect to Salesforce instance here you need to press Ctrl shift p type sftx and you should find in command called authorize and Arc click on it now it will ask you for uh you know URL so because we are using a Developer Edition org it is always log into salesforce.com for production aux as well it is login.salesforce.com if you are working in a company and they they might have given you some access to some sandbox then it will be test.salesforce.com so all the non-production environments and Developer Edition uh environments will be using login.salesforce.com and rest of the things so I think I think I said it uh the other way so all the all non-production aux will be using testoster salesfor.com and if you're logging into production then you have to go for uh blogger.salesforce.com let's select this one here you can give it any name I'll just keep it to default press enter thank you here you will be entering your Salesforce credentials it is already appearing here because I have logged it already click on login if you're doing it for the first time it might ask you or to click on allow if you are giving permission uh to vs code to access your Salesforce stuff so once you are logged in what you can do you can um if you leave anything you can deploy anything here now let's so this we connected our source sandbox okay now let me finish my sign up process for the other org I just got an email time okay so for uh testing purpose what I will do um suppose if you want to create a field okay on account object we will try to deploy this field first go to Fields relationships now here click on new or uh maybe I think we should try with some Apex class let's go to so that I can show you how you use vs code now in your vs code uh your org is connected okay if you want to create an apex class press Ctrl shift p type Apex and you will see one command called new Apex class just come on children exploration context okay I don't know what that means foreign let me try to create Apex class from here no but it is connected to our org thank you Apex class you need to press Ctrl shift p and this is the command I mean not new Apex class uh this is something else and I got confused about this about this uh you click on sfdx create new create Apex class it will ask you for a name for example uh test class one and it will ask you for the folder it will directly take this default directory so you can see it's very easy to create a class in Salesforce now in this class I will be just adding one statement I will be adding a comment so now you have saved this so this class has not been deployed to any sandbox it's in your local always remember that whenever you create anything in vs code here it will remain in your local always until you deploy it to your uh sandbox so in order to so if you will just to make sure if you will go to your uh setup here just I'll show you through developer console if that class is present or not so this is the class name we will try to find this class here let me close down these things open and classes you cannot see any class right now close it now if you want to deploy this class to this Source sandbox what you need to do is uh you need to select both of these files right click on it and deploy source to Arc you will see deployment will start from here and if you get any error you will see here now it says successfully now let's go back to our developer console click on open click reopen it sometimes Salesforce might be very confusing you might want to refresh your pages uh if you have made any changes see we already see one class here or test class one let's check if that's the same yeah this is the one so now you have uh already created one class now what if you want to deploy this class to another sandbox so let us just log into that another sandbox which we which I created in this video and username was manvinder at how to salesforce.com we have successfully logged in no there are multiple ways to deploy other stuff but I will show you the very straightforward one now in your vs code right now only one org is connected you have one class which needs to be deployed what you need to do there may be scenarios where you will be deploying a lot of components right there will be hundreds of components so first you need to update this file so right now this file has a lot of stuff which is which came with this file when we you know installed it when we created the Salesforce project by default uh to update this file there is an extension called Salesforce uh exam practice XML generator you need to press Ctrl shift p search for package and if you have this extension extension installed then you will see this uh press enter now we just want to deploy that class nothing else right so first of all you need to click on clear all search for Apex class and if you will click on this Arrow you will find a list of classes which are present in your org not in your local but in your Arc okay this is the class which you want to deploy click on update package XML file you will see your file has been updated now because we already have this file in our local so we don't need to retrieve otherwise if you don't have any components in your local you need to right click on this file and retrieve them first in your vs code retrieve source and manifest from org uh but because we just uh we are just deploying this class so I want I I will just skip that step uh now we want to deploy it to another sandbox right so what you need to do you just need to authorize that destination sandbox in this vs code press Ctrl shift p type sfdx and there will be this command called authorization Arc click on it because it's a Developer Edition again uh select login with salesforce.com just keep it default press enter and here it will ask you to login so this is my new username uh new account which I created in this video click on login uh see as I told you if you will be doing it for the first time it will ask you to allow if you want to uh you know permit Visual Studio code to allow you to access your Salesforce data click on allow no because you have authorized this sandbox if you will go to vs code here uh the connected sandbox is this one with how to Salesforce now because we already have this Apex Plus in our local what do you need to do you just need to right click on package XML file and click on deploy sourcing manifest to Arc let's do it okay it went successfully now if you want to check if it has been deployed successfully or not you in setup you go to Apex classes and you will see our classes here last Modified by how to Salesforce and you can also check the time it's 1 26 am all right so this is how we deploy components this was just one class you your comp your deployment might be a little bit uh complex depending on list of uh components how huge it is and how you know uh What uh how many uh types of components you have and in in our deployment we always have some pre-deployment steps post deployment steps and there are other methods as well which I will be covering in my other videos I am working on entire series on deployment process so thank you so much guys for watching this video uh until the end and please subscribe to my channel and share this video If you think it can help anyone uh with Salesforce thanks and have a nice day
Info
Channel: HowToSalesforce
Views: 4,588
Rating: undefined out of 5
Keywords:
Id: B2d3CBhfRhc
Channel Id: undefined
Length: 21min 13sec (1273 seconds)
Published: Tue Feb 21 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.