Forcetrails: How to deploy advanced territory management using vs code

Hello Trailblazers!!

As of now until the Spring 2020 release, we can not add Advance Territory Management in the changeset. But there is another way, we can deploy these changes with Salesforce CLI and VS Code.
 

Prerequisite: JDK, VS Code installed with Salesforce Extension Pack, Salesforce CLI. Follow the instructions to set up.

Assume that you need to deploy the Advanced Territory Management changes from Sandbox to Production. You can also use these steps to deploy from one sandbox to another.

Follow the below steps.
  1. First, create the VS code project for Sandbox.
  2. Open VS code, create a new project, Ctrl/⌘ -> Shift ->P, type  "Create Project with Manifest".
  3. Select the folder to save the project.
  4. Now authorize the source org, using Authorise an Org command.
  5. Now we need to retrieve the territory changes from the source org. Before that add the below code in your package.xml file.
    <types>
        <members>*</members>
        <name>Territory2Model</name>
    </types>
    <types>
        <members>*</members>
        <name>Territory2</name>
    </types>
    <types>
        <members>*</members>
        <name>Territory2Rule</name>
    </types>
    <types>
        <members>*</members>
        <name>Territory2Type</name>
    </types>
  6. Right-click the manifest file and select "Retrieve Source in Manifest From Org". wait till the changes are retrieved. After successful retrieve, you will see below folders in your project.
    Territories folders in project
  7. Create a new VS code project for the destination Production (sandbox if needed).  Follow steps 1 through 4 to create a new project. Ignore if you already have one.
  8. Now copy the folders and all theirs contents "territory2Models", "territory2Types".
    copy territory folders
  9. Paste the copied folders into the destination project's "default" folder.
  10. Now its time to deploy. Please note that you need to deploy the "territory2Types" folder first. So right-click that folder and select "Deploy Source to org".
  11. Next, deploy the "territory2Models" folder. 
Now check in the destination org you should have the changes. Let me know if you face any issues.


Resources

No comments :
Post a Comment

Hi there, comments on this site are moderated, spams and promotions will be deleted. If you have any concern, or if you are not able to comment for some reason, reach email us at rahul@forcetrails.com