You need to sign in to do that
Don't have an account?
chris04
MALFORMED_ID creating custom SObject instance with a FieldType.Lookup using Partner API
Hi all,
I've successfully used the Metadata API to create two custom objects, one a parent, and one a child with a reference field of type Lookup pointing at the parent. I am able using the Salesforce UI to populate that child's reference field to the parent, however I am getting a "MALFORMED_ID", "id value of incorrect type" error when doing it using the Partner API. Is there somethign special I need to do when creating the reference field's MessageElement object?
Thanks,
Chris
Message Edited by chris04 on 07-10-2008 12:20 PM
Message Edited by chris04 on 07-10-2008 12:21 PM
I've successfully used the Metadata API to create two custom objects, one a parent, and one a child with a reference field of type Lookup pointing at the parent. I am able using the Salesforce UI to populate that child's reference field to the parent, however I am getting a "MALFORMED_ID", "id value of incorrect type" error when doing it using the Partner API. Is there somethign special I need to do when creating the reference field's MessageElement object?
Thanks,
Chris
Message Edited by chris04 on 07-10-2008 12:20 PM
Message Edited by chris04 on 07-10-2008 12:21 PM
<TestObject__c xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">123456</TestObject__c>
If I describe the TestObject__c (parent), and Part__c (child), they look like the following:
----------- Describe SObject -----------
Name: TestObject__c
Label: TestObject
Plural Label: TestObjects
Number of fields: 16
Field {id}: Record ID
Field {reference}: Owner ID
Field {boolean}: Deleted
Field {string}: TestObject Name
Field {datetime}: Created Date
Field {reference}: Created By ID
Field {datetime}: Last Modified Date
Field {reference}: Last Modified By ID
Field {datetime}: System Modstamp
Field {date}: Last Activity Date
Field {string}: ObjectID
Field {string}: EventID
Field {string}: ACTION
Field {string}: FromUserID
Field {datetime}: Timestamp
Field {string}: FromUser
----------- Describe SObject -----------
Name: Part__c
Label: Part
Plural Label: Parts
Number of fields: 14
Field {id}: Record ID
Field {reference}: Owner ID
Field {boolean}: Deleted
Field {string}: Part Name
Field {datetime}: Created Date
Field {reference}: Created By ID
Field {datetime}: Last Modified Date
Field {reference}: Last Modified By ID
Field {datetime}: System Modstamp
Field {date}: Last Activity Date
Field {string}: quanitity
Field {reference}: TestObject
Field {datetime}: Timestamp
Field {string}: ObjectID
Finally, if I debug and examine the Field object during the describe call for that field, the soapType = "tns:ID" and the type = "reference".
I think I just need to understand how I can indicate on the MessageElement object the appropriate type for a field that is a reference.
Chris
Message Edited by chris04 on 07-10-2008 01:02 PM
Upserting allows use of an ExternalID, i.e. 123456, etc.
However in order to reference a Parent object from a Child object, you must use the Parent's actual Salesforce ID and not an ExternalID or Name.
I tried this and it appears to work, thanks very much for the help.
I could see it being useful to be able to be able to set the reference to the Parent using its ExternalID if it has one. As it stands now, you need to know the Parent's ID or query the API to get the Parent's ID in order to construct a Child that references the Parent, even though I know the ExternalID of the Parent at the time I am attemping to create the Child.
Thanks again for the response,
Chris
Message Edited by chris04 on 07-10-2008 02:09 PM
e.g. instead of
<accountId>001...</accountId>
you'd do
<account>
<type>account</type>
<myExtId__C>12345</myExtId>
</account>
where accountId is the name of hte lookup field, and account is the name of the relationship.
Message Edited by SimonF on 07-10-2008 02:38 PM