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
shinmnshinmn 

Duplicate <sf:Id> tags

Hello,

 

I am using the current partner WSDL (C#/VS2008)

 

 

<!-- Salesforce.com Partner Web Services API Version 15.0 Generated on 2009-05-14 18:45:10 +0000. Copyright 1999-2009 salesforce.com, inc. All Rights Reserved -->

 

 

 

 to query for some basic Account, Contact, & Opportunity, etc. information.

Within the results, the <sf:Id> tag is repeated as excerpted below.  I searched but was not sucessful in determining if this is a known issue.

 

<records xsi:type="sf:sObject" xmlns="urn:partner.soap.sforce.com"> <sf:type>Contact</sf:type> <sf:Id>0038000000TrjoBAAR</sf:Id> <sf:Id>0038000000TrjoBAAR</sf:Id> <sf:FirstName>Edna</sf:FirstName> <sf:LastName>Frank</sf:LastName> </records> <records xsi:type="sf:sObject" xmlns="urn:partner.soap.sforce.com"> <sf:type>Opportunity</sf:type> <sf:Id>0068000000LOVjkAAH</sf:Id> <sf:Id>0068000000LOVjkAAH</sf:Id> <sf:Name>GenePoint Standby Generator</sf:Name> <sf:Description xsi:nil="true" /> </records>

 

Is this a known/fixed issue?  Thanks.

SuperfellSuperfell
The first Id is for the Id element defined in the SObject type, the 2nd one appears to preserve the mapping from your query to the xsd:any section, i.e. you don't need to do anything special if you query Id, it'll appear in the xsd:any section just like any other field.
shinmnshinmn

Hi Simon,

 

I'm afraid I don't have enough exposure to understand the second part of your answer-

 

"the 2nd one appears to preserve the mapping from your query to the xsd:any section, i.e. you don't need to do anything special if you query Id, it'll appear in the xsd:any section just like any other field." 

 

Is it expected that when you query for an Id that one will receive two <sf:Id> elements as I originally posted?   Any further context you can provide will be gratefully received.

 

Thank you

SuperfellSuperfell

select name, foo, id from bar

 

will return an xsd:any array that contains the elements for name, foo & id, in the order you selected them in, so you can simply index into the array based on the field position in the query. 

 

The Id is also populated in the xml in the spot defined by the sobject schema definition, so that you can call .Id on the sobject type.

 

The response of the XML is dictated by the partner WSDL/Schema, if you're not using a schema based tool to access the XML data, then yes, the double Id element looks weird, but it is by design. 

shinmnshinmn

Ah, got it, thanks.

 

Just to paraphrase... Inorder to support the Id property of an sObject, an implicit 'SELECT Id' is made on ones behalf.  If an additional, explicit, 'SELECT Id' is added to the query, the result is two identical <sf:Id> tags.

Dr WhoDr Who

I'm not sure why you would have this by design....

 

However if I perform a query and don't include the 'Id' field I get a result such as:

 

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sf="urn:sobject.partner.soap.sforce.com">
  <soapenv:Body>
    <queryResponse>
      <result xsi:type="QueryResult">
        <done>true</done>
        <queryLocator xsi:nil="true"/>
        <records xsi:type="sf:sObject">
          <sf:type>Enquiry__c</sf:type>
          <sf:Id xsi:nil="true"/>
          <sf:Name>0000001</sf:Name>
        </records>
        <size>1</size>
      </result>
    </queryResponse>
  </soapenv:Body>
</soapenv:Envelope>

 

But if I do include the "Id" in my query. I get duplicates.

 

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sf="urn:sobject.partner.soap.sforce.com">
  <soapenv:Body>
    <queryResponse>
      <result xsi:type="QueryResult">
        <done>true</done>
        <queryLocator xsi:nil="true"/>
        <records xsi:type="sf:sObject">
          <sf:type>Enquiry__c</sf:type>
          <sf:Id>a0090000002WK2fAAG</sf:Id>
          <sf:Id>a0090000002WK2fAAG</sf:Id>
          <sf:Name>0000001</sf:Name>
        </records>
        <size>1</size>
      </result>
    </queryResponse>
  </soapenv:Body>
</soapenv:Envelope>

 

This really is a case of "Double or Nothing".

 

Does anyone have a good regex or another method that can accurately discard the duplicate even when there are multiple records and related record structures in the XML?

 

Regards

 

The Doc.