Context: I am using the following package.xml file to create a package containing the list of all SHARING RULES that are under the Lead object with the name starting with AmericaLeads and all opportunities starting with AmericaRegions. They are all under the category of "SharingOwnerRule"

Q: I know v32.0 and later, we can use wild card. However, before deploying, Is there a way to validate if the wild card I have used actually retrieves all the sharing rules as desired.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">

If you're using ANT, you can set up a simple task that only performs a retrieve.

An example, based off of the build.xml file that I use

<target name="testRetrieve">
    <mkdir dir="testRetrieve" />
    <sf:retrieve username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" retrieveTarget="testRetrieve" unpackaged="package.xml"/>

If you then execute that task, you'll see a folder appear in your specified retrieveTarget that contains the SharingOwnerRules that were specified in your package.xml file.

According to the sharing rules documentation in the metadata api guide

In API version 33.0 and later, components are stored in the sharingRules folder and their file name matches the object name with the suffix .sharingRules. Criteria-based, owner-based, and territory-based sharing rules are all contained in a object.sharingRule file.

Prior to API version 33.0, SharingRules components are stored in their corresponding object directory and the file name matches the object name. For example, the accountSharingRules directory contains an Account.sharingRules file for account sharing rules. SharingRules for custom objects are stored in the customObjectSharingRules directory, which contains files with the .sharingRules extension such as ObjA__c.sharingRules, where ObjA refers to the developer name of a custom object type.

So depending on the API version that you're using in your package.xml, you'll look for a different file in a different directory. However, in both cases, there should be a single file that you can look through that contains the sharing owner rules (and only those rules) that your package.xml specifies.


You can validate this by doing an ant retrieve and seeing if the rules being obtained are the ones you will eventually want to migrate elsewhere.

Documentation in ant retrieve can be found here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.