Compare File against the Source Org in VS Code

Hello Ohana, One of the major problems that we face while working with #VS Code in Non Source Controlled Salesforce Environments is Code Overwrite, I am not very sure about everyone but this was the problem we were facing in our org due to so many developers working in single sandbox and icing on the cake was that we were not using any version control tools in lower orgs. I have explained step by step process below how to overcome this issue with Source Diff feature in #Salesforce CLI, Since its not generally available yet we have installed it as #CLI Plugin. 



Step 1 Installation . Go to Command Prompt for windows or Terminal for Mac and type below command
             sfdx plugins:install @salesforce/sfdx-diff
Some time due to digital signature verification unavailability it may ask you to confirm if you want to    install it, we will select as yes and proceed and you would see the success message like  below after installation. 


Step 2 Verification . If your VS code is already open you can verify if the plugin is available by right    clicking any apex class or any of the supported metadata types and you would see  the option available  at the bottom. We will mention the list of supported metadata and api  version in step one. If the option is not yet appearing in your vs code please check the api version of plugins and make sure you have updated everything. 
    


Step 3 Usage and Supported Metadata. Now that we have installed and verified that our plugin is         installed successfully,  its time to put it to use and stop worrying about code overwrite while  saving new  changes in a shared class/ component/file. For purpose of this demo we have create a class and added one additional method in the class from dev console which is not yet available in VS code,
 but before refreshing it from org i have made some changes locally and i want to  compare   my changes against the class which is available in my Sandbox. I have opened my  apex class  and selected the diff file against org option after right clicking on the class and it will  compare my class against the org and show the differences like below pic.



        you can see method three which i have added via dev console is highlighted in the red on the left 
        side which you can merge in your class before you save and deploy to your org. 
        
     Supported metadata and Api versions : Since this feature is not in GA so this may change once it         available but as of now below is list of metadata it supports : 
  1. Apex Class
  2. Apex Trigger
  3. Aura Application
  4. Aura Component
  5. Aura Event
  6. Aura Interface
  7. Aura Token
  8. Custom Label
  9. Layout
  10. Lightning Web Component
  11. Permission Set
  12. Visualforce Component
  13. Visualforce Page
 Api Versions Supported : Starting in version 46.11.0, a new menu option SFDX: Diff File Against Org appears when you right-click an  open (supported metadata) file listed above.

Hope it helps in resolving those code overwrite nightmares, Feel free to suggest any changes or feedback in the comment section below. Happy Learning !!! 













Comments

  1. Grt post👍Can you plz explain the VS code installation in next post.

    ReplyDelete
  2. Since there was a lot of content available online for installation setup so i presumed people would have installed it but i can help if there is any specific query.

    ReplyDelete

Post a Comment

Popular posts from this blog

Flosum Certified Professional Exam Certification Process and Tips

Copado Administrator Exam Certification Process and Tips