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
TesterInSkyTesterInSky 

'describeSObjects' Call returns more than one 'referenceTo' node for 'Owner' field, why?

When using the Partner WSDL, trying to parse the schema information for a particular SObject, I noticed that there are more than one 'referenceTo' node being returned. One is: Group, and the other one is: User . For I need to gather the reference type information from this node, so I got confused by this, I do not know which one I need to use.

I would like to know if this is an expected behavior. And is there a good way for me to know the actual reference type for a particular element.

I analyzed the schema defined in Enterprise WSDL, I noticed that for some of SObjects, the Owner is refer to 'User', but for some other Owner elements, they refer to 'Name'. My guess is, when there are two 'referenceTo' nodes for Owner, then I should set the type to 'Name', and I need to set it to 'User' when there is only one 'referenTo' Node with the 'User' as the its value.

Please confirm me whether the above assumption is correct. And I would also like to know is there any build-in logic I could follow to generate my own SObject schema? And how many fields are there that I need to take care of by using the same way I mentioned above or follow the logic of Salesforce to do the handling.

Thanks Very Much, Please Reply As Soon As Possible.
craigmhcraigmh

I know that this is an old topic, but it keeps coming up in my searches for another question I have on referenceTo.

 

I'd like to add that if you do a describe on the User sObject, you'll see that DelegatedApproverId field references either the Group or User sObject. Since it can reference multiple sObjects, the describe is returned as a List of Schema.sObjectType in Apex.

See the getReferenceTo info in this link:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_fields_describe.htm