Reply
Contributor
Yoxel
Posts: 7
0
Accepted Solution

Can not create a custom field in a junction object

Hello,  I am trying to create a custom junction object, and one of the relationship fields is supposed to point to Contact.

I can not find any documentation that would explain well which properties exactly and how need to be set for master-detail relationship fields. As a result the service silently ignores my creation request. Here is the first field that I am trying to add but it would not add:


fullNAme=MyCustomObject__c.Contact_c
label=Contact
type=FieldType.MASTER_DETAIL
rteferenceTo=Contact
relationshipLabel=Participant
relationshipName=Contact.Id
relationshipOrder=0

 

 Any help would be really appreciated.

 

-Alexey

Contributor
Yoxel
Posts: 7
0

Re: Can not create a custom field in a junction object

 Actually even adding a LOOKUP field on a regular custom object does not seem to work, simply ignored by the service without any errors. Non-relationship fields can be added just fine but something is wrong with adding relationship fields.

Please advise.

Contributor
Yoxel
Posts: 7
0

Re: Can not create a custom field in a junction object

Ok, I think I finally figured this out. Here is the correct settings:

 

fullNAme=MyCustomObject__c.Contact_c
label=Contact
type=FieldType.MASTER_DETAIL
rteferenceTo=Contact
relationshipLabel=Participant
relationshipName=MyCustomLookupName  <---
relationshipOrder=0

 

"Contacts" was not allowed for the Contact object

Regular Contributor
JPClark3
Posts: 76
0

Re: Can not create a custom field in a junction object

It looks like you've figured this out already.

 

I have found that, when working with the metadata API, it is a good practice to investigate the XML files used in the IDE to see how the attributes are used.

 

In this case I would have looked at an existing Master-Detail relationship in a .object file. It will look something like this. You can use these values as a guide to the attributes in the metadata API.

 

<fields>
     <fullName>Pay_Period__c</fullName>
     <deprecated>false</deprecated>
     <externalId>false</externalId>
     <inlineHelpText>The Pay Period for this timesheet.</inlineHelpText>
     <label>Pay Period</label>
     <referenceTo>Pay_Period__c</referenceTo>
     <relationshipName>Timesheets</relationshipName>
     <relationshipOrder>0</relationshipOrder>
     <trackHistory>false</trackHistory>
     <type>MasterDetail</type>
     <writeRequiresMasterRead>false</writeRequiresMasterRead>
</fields>

 

Contributor
Yoxel
Posts: 7
0

Re: Can not create a custom field in a junction object

yes, thank you. it's my first time using this api and I was not properly checking the status/errors, basically missing an important error message. finally figure it out. still alot to learn but I seem to be moving along just fine now.