• Lousie Apostol
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

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