sfdx-isv / territory-management-toolkit

The Territory Management Toolkit (TM-Tools) is a Salesforce CLI Plugin that provides tools for simplifying the migration of a Salesforce org from Territory Management (TM1) to Enterprise Territory Management (TM2).
BSD 3-Clause "New" or "Revised" License
8 stars 0 forks source link

territory2Rule Metadata components have an extra "Account" referenced in their field path #1

Closed VivekMChawla closed 5 years ago

VivekMChawla commented 5 years ago

The end result of a tm-tools:tm1:transform operation results in an extra Account being prepended t the field key in the ruleItems set.

Here's an example of a malformed metadata component:

<?xml version="1.0" encoding="UTF-8"?>
<Territory2Rule xmlns="http://soap.sforce.com/2006/04/metadata">
    <active>true</active>
    <name>VT-Rule1101</name>
    <objectType>Account</objectType>
    <ruleItems>
        <field>Account.Account.Territory_vod__c</field>
        <operation>contains</operation>
        <value>;1101;</value>
    </ruleItems>
</Territory2Rule>

The <field> tag should say Account.Territory_vod__c, but instead it says Account.Account.Territory_vod__c

VivekMChawla commented 5 years ago

The relevant code is found here: https://github.com/sfdx-isv/territory-management-tools/blob/6f58c8304ab6a931a305e23b5037858927a68b79/src/modules/tm-tools-objects/territory2-rule.ts#L149-L150

I've added this check to ensure that every field is prepended by Account.. Most field names in the CSV file that serves as the source for this transform ARE PRE-PENDED by Account. but some fields are not.

This code ensures every field name gets Account. prepended. Hopefully this fixes things but I'll keep this bug open a bit until we do more tests.

VivekMChawla commented 5 years ago

The fix mentioned in the previous comment appears to have held up. Closing this issue.