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
DDG_LJUDDG_LJU 

Create custom object parent child relationship via metadata api.

Hi guys...

 

I want to create two objects and link them via a parent child relationship in C# using the Metadata API.

 

I can create objects and 'custom' fields for the objects via the metadata, but the service just ignores the field def for the realtionship.

 

By snipet for the fields are as follows :

 

CustomField[] fields = new CustomField[] { new CustomField()
{
type = FieldType.Text,
label = "FirstName",
length = 50,
lengthSpecified = true,
fullName = "LJUTestObject__c.FirstName__c"
},
new CustomField()
{
type = FieldType.Text,
label = "LastName",
length = 50,
lengthSpecified = true,
fullName = "LJUTestObject__c.Lastname__c"
},
new CustomField()
{
type = FieldType.Text,
label = "Postcode",
length = 50,
lengthSpecified = true,
fullName = "LJUTestChildObject__c.Postcode__c"
},
new CustomField()
{
type = FieldType.MasterDetail,
//label = "Postcode",
relationshipLabel = "PostcodeLookup",
relationshipName = "LJUTestObject__c.LJUTestObject_Id__c",
relationshipOrder = 0,
relationshipOrderSpecified = true,
fullName = "LJUTestChildObject__c.Lookup__r"
}
};

 

The parent object looks like

 

LJUTestObject

ID,

FirstName, Text(50)

        LastName, Text(50)

 

the child objext looks like 

 

LJUTestChildObject

ID,

        Postcode, Text(50)

 

I want to link the parent to the child so one "LJUTestObject", can have many "LJUTestChildObjects"

 

What values do I need for FieldType, RelationshipName, and RelationshipOrder to make this happen?

 

Thanks guys

 

LJU

YoxelYoxel

Does metadata service simply does not allow creating relationship fields?

Any news here?

Lousie ApostolLousie Apostol
hi! were you able to implement this one? i'm having the same trobule now..