function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Roberto Drumond Da Silva 10Roberto Drumond Da Silva 10 

Error Importing Duplication Rules via Change Sets or ANT - Error: SortOrder must be in sequential order from 1

Hi Ohana Family!

I am getting this error (see below)... when trying to import 2 new duplication rules into my sandbox (via ANT but also via change sets). The sandbox has 3 other contact rules.

It seems not possible to import duplication rules partially due to the order, is this the case? What is the best way to add new duplication rules into a sandbox (or production); it seems that since Winter '17 duplication rules are supported but I cannot import just 2 new rules because I get this order issue. Any ideas???

Duplication Rule XML contains the Sort Order which I've tried to manually change in the XML in ANT to be a new number (there are 3 existing Contact rules on my sandbox) but keep getting this error.

*********** DEPLOYMENT FAILED ***********

Total time: 15 seconds
$ ant deployUnpackaged
Buildfile: /Users/me/Documents/salesforce_ant_38.0/nm-dev/build.xml

deployUnpackaged:
[sf:deploy] Request for a deploy submitted successfully.
[sf:deploy] Request ID for the current deploy task: 0Af2500000QX8HKCA1
[sf:deploy] Waiting for server to finish processing the request...
[sf:deploy] Request Status: InProgress
[sf:deploy] Request Status: Failed

BUILD FAILED
/Users/rdrumonddasilva/Documents/salesforce_ant_38.0/nm-dev/build.xml:31: 
*********** DEPLOYMENT FAILED ***********
Request ID: 0Af2500000QX8HKCA1

All Component Failures:
1.  duplicateRules/Contact.Contact_relatienummer_and_email.duplicateRule -- Error: SortOrder must be in sequential order from 1.

*********** DEPLOYMENT FAILED ***********

These are the XMLs:
<?xml version="1.0" encoding="UTF-8"?>
<DuplicateRule xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <actionOnInsert>Block</actionOnInsert>
    <actionOnUpdate>Block</actionOnUpdate>
    <alertText>U creeert een dubbele relatie. Zoek de oorspronkelijke relatie op en gebruik deze.</alertText>
    <description xsi:nil="true"/>
    <duplicateRuleFilter>
        <booleanFilter xsi:nil="true"/>
        <duplicateRuleFilterItems>
            <field>00N24000008H1u2</field>
            <operation>notEqual</operation>
            <value>null</value>
            <sortOrder>1</sortOrder>
            <table>Contact</table>
        </duplicateRuleFilterItems>
        <duplicateRuleFilterItems>
            <field>Email</field>
            <operation>notEqual</operation>
            <value>null</value>
            <sortOrder>2</sortOrder>
            <table>Contact</table>
        </duplicateRuleFilterItems>
    </duplicateRuleFilter>
    <duplicateRuleMatchRules>
        <matchRuleSObjectType>Contact</matchRuleSObjectType>
        <matchingRule>Match_op_relatienummer_email</matchingRule>
        <objectMapping xsi:nil="true"/>
    </duplicateRuleMatchRules>
    <isActive>false</isActive>
    <masterLabel>Contact relatienummer email</masterLabel>
    <securityOption>EnforceSharingRules</securityOption>
    <sortOrder>1</sortOrder>
</DuplicateRule>

<?xml version="1.0" encoding="UTF-8"?>
<DuplicateRule xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <actionOnInsert>Block</actionOnInsert>
    <actionOnUpdate>Block</actionOnUpdate>
    <alertText>U creeert een dubbele relatie. Zoek de oorspronkelijke relatie op en gebruik deze.</alertText>
    <description xsi:nil="true"/>
    <duplicateRuleFilter>
        <booleanFilter xsi:nil="true"/>
        <duplicateRuleFilterItems>
            <field>00N24000008H1u2</field>
            <operation>notEqual</operation>
            <value>null</value>
            <sortOrder>1</sortOrder>
            <table>Contact</table>
        </duplicateRuleFilterItems>
        <duplicateRuleFilterItems>
            <field>Phone</field>
            <operation>notEqual</operation>
            <value>null</value>
            <sortOrder>2</sortOrder>
            <table>Contact</table>
        </duplicateRuleFilterItems>
    </duplicateRuleFilter>
    <duplicateRuleMatchRules>
        <matchRuleSObjectType>Contact</matchRuleSObjectType>
        <matchingRule>Match_op_relatienummer_telefoonnummer</matchingRule>
        <objectMapping xsi:nil="true"/>
    </duplicateRuleMatchRules>
    <isActive>false</isActive>
    <masterLabel>Contact relatienummer telefoonnummer</masterLabel>
    <securityOption>EnforceSharingRules</securityOption>
    <sortOrder>2</sortOrder>
</DuplicateRule>
 
Best Answer chosen by Roberto Drumond Da Silva 10
Roberto Drumond Da Silva 10Roberto Drumond Da Silva 10
I resolved the issue by importing the 5 duplication rules (3 existing ones + 2 new ones) having the order changed manually in the XML used in ANT.  As far as I can see this issue cannot be solved via change sets (but you need ant if you want to change the order of the duplication rules). I presume change sets will work if the 2 new rules are added at the end (so there is no need to change the order of the existing rules).

All Answers

Roberto Drumond Da Silva 10Roberto Drumond Da Silva 10
I resolved the issue by importing the 5 duplication rules (3 existing ones + 2 new ones) having the order changed manually in the XML used in ANT.  As far as I can see this issue cannot be solved via change sets (but you need ant if you want to change the order of the duplication rules). I presume change sets will work if the 2 new rules are added at the end (so there is no need to change the order of the existing rules).
This was selected as the best answer
Frédéric ProvotFrédéric Provot
Thank you for this information, this was helpfull. I made the 'error' of setting my contact duplication rule in first position, as the default one is inactive. Then the validation of the changeset was impossible with the not so much meaningfull message "SortOrder must be in sequential order from 1". This error should have been "Sortorder value conflict". As I deleted the default inactive rule to test, it was a mess to make all work!