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
Marcel dos SantosMarcel dos Santos 

Enterprise WSDL with Name or SObject

I have two organizations, one for development and another for production/sandbox.

When I generate a WSDL from production/sandbox I have some lookup relationships mapped as Name.
If I generate the WSDL from the development environment instead, I get the same relationships mapped as SObject.

Here is an example for Lead:

Development:
<complexType name="Lead">
<complexContent>
<extension base="ens:sObject">
<sequence>
<element name="AcceptedEventRelations" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="ActivityHistories" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="Address" nillable="true" minOccurs="0" type="tns:address"/>
...
<element name="Owner" nillable="true" minOccurs="0" type="ens:sObject"/>
<element name="OwnerId" nillable="true" minOccurs="0" type="tns:ID"/>
...
</sequence>
</extension>
</complexContent>
</complexType>

Production:
<complexType name="Lead">
<complexContent>
<extension base="ens:sObject">
<sequence>
<element name="AcceptedEventRelations" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="ActivityHistories" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="Address" nillable="true" minOccurs="0" type="tns:address"/>
...
<element name="Owner" nillable="true" minOccurs="0" type="ens:Name"/>
<element name="OwnerId" nillable="true" minOccurs="0" type="tns:ID"/>
...
</sequence>
</extension>
</complexContent>
</complexType>


You can see that the Owner is mapped as Name in production but sObject in development.
That happens thoughout the whole wsdl. There is no Name object in development.

Both are using the same API version:

<soap:address location="https://login.salesforce.com/services/Soap/c/33.0/0DFi0000000CjGX"/>

<soap:address location="https://login.salesforce.com/services/Soap/c/33.0/0DFE0000000TYR9"/>

Is there a way to make both organizations map this multi-type lookup relationships to Name?
 

ShashankShashank (Salesforce Developers) 
The reason could be that one org is a developer edition org and the other is an enterprise edition org.
Kirill_YunussovKirill_Yunussov
This is due to an object being able to be owned by more than one other type of object - like Case, for example, could be owned by User or a Group.  For such objects, the relationship is replaced with the generic "Name".

In your case, the orgs are probably at difference release versions, and in one the object can only be owned by User, while in the other by User or Group - hence a different name for the relationship.

Salesforce docs:

Name
Non-queryable object that provides information about foreign key traversals when the foreign key has more than one parent.
This object is used to retrieve information from related records where the related record may be from more than one object type (a polymorphic foreign key). For example, the owner of a case can be either a user or a group (queue). This object allows retrieval of the owner name, whether the owner is a user or a group (queue). You can use a describe call to access the information about parents for an object, or you can use the who, what, or owner fields (depending on the object) in SOQL queries. This object cannot be directly accessed.

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_name.htmhttps://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_name.htm

______________________

The error I myself got because of this is below, when existing code broke after WSDL update.   Including the error here for future reference.

java.lang.ClassCastException: com.sforce.soap.enterprise.sobject.Name cannot be cast to com.sforce.soap.enterprise.sobject.User