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
zgcharley_09zgcharley_09 

Miss metadata for Lookup field in Enterprise WSDL

Hi,

 

I create a lookup field for Account object and this field related to Account itself too. Now i set the "Field Name" and "Child Relationship Name" to same value "TestLookupAccount". Click next and save.

 

Then i download the enterprise wsdl, and find the schema of this lookup field like this:

<element name="TestLookupAccount__c" nillable="true" minOccurs="0" type="tns:ID"/>
<element name="TestLookupAccount__r" nillable="true" minOccurs="0" type="tns:QueryResult"/>

 But if i set the "Field Name" and "Child Relationship Name" with different values, such as "TestLookupAccount" for "Field Name" and "TestLookupAccountChild" for "Child Relationship Name", then i will get the schema in enterprise wsdl file like this:

<element name="TestLookupAccountChild__r" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="TestLookupAccount__c" nillable="true" minOccurs="0" type="tns:ID"/>
<element name="TestLookupAccount__r" nillable="true" minOccurs="0" type="ens:Account"/>

 It seems Salesforce omit one element if I set same value for "Field Name" and "Child Relationship Name". Can anyone tell me why?  Is it allowed to set the same value for them?

 

Thanks

 

 

Best Answer chosen by Admin (Salesforce Developers) 
dkadordkador

There are logically three fields exposed when creating a lookup relationship from an object to itself:

 

1.) The field itself (which contains the foreign key).

2.) The child to parent relationship (which gives you access to fields on the single parent related to the current child).

3.) The parent to child relationship (which gives you access to fields on the potentially many children related to the current parent).

 

They need to have unique names for them to all work.  If you don't differentiate between the relationship names, then we have to pick one.  In this case, we choose the parent to child relationship.

 

The appropriate thing to do is have unique names.