I'm currently struggling in creating a ContactOwnerSharingRule via the Salesforce Metadata API.

I am using Ruby and the metaforce gem.

I am using the the create-method which calls out to the SOAP API. the call then looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://soap.sforce.com/2006/04/metadata" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://soap.sforce.com/2006/04/metadata">
      <ins0:metadata xsi:type="ins0:ContactOwnerSharingRule">

At this point it doesn't matter what I put into sharedFrom or sharedTo, because the error message is something else:

Required field is missing: Parent

I have not found a reference to a parent field in any documentation nor the Metadata WSDL file.

If I set the parent field to something, I get this error message:

 Must specify a {http://www.w3.org/2001/XMLSchema-instance}type attribute value for the {http://soap.sforce.com/2006/04/metadata}parent element

So my question is:

Hast anyone ever created a SharingRule via the metadata API? And if so, how does the SOAP request look like?

2 Answers 2


I found a work-around for this issue, although I was never able to get it working as a CustomObjectCriteriaBasedSharingRule type, I was able to get this working with the (I think newer?) SharingCriteriaRule type. Here is some example XML:

<createMetadata xmlns="http://soap.sforce.com/2006/04/metadata">
  <metadata xsi:type="SharingCriteriaRule">
    <description>Grants standard users access to public views</description>

The only syntactical difference between SharingCriteriaRule and CustomObjectCriteriaBasedSharingRule that I encountered was label/name fields. Hope this helps someone out there!


Looks like this may be a known issue, click the "This Issue Affects Me" link if you wish

Here is the link to the known issue:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .