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
jqcoffeyjqcoffey 

Creating a detail item in a Master-Detail or Lookup Relationship

All,
    I'm having a hard time trying to get a detail item in my master/detail relationship to insert correctly.  I've populated the $WWW::Salesforce::Constants::TYPES object with my custom fields, but I still end up with this:

Unable to find a de-serializer for the type ID

It looks like the API won't allow the creation of detail objects (or insertion of any record that contains a tns:ID SOAP type).

Is that correct?  Am I an idiot?  Anyone have any clues?

Thanks,
Justin
Park Walker (TAGL)Park Walker (TAGL)
You can certainly insert records with tns:Id type fields in them, but you cannot pass the Id field when creating an item. When creating a detail record you need to put the Id of the  parent object into the appropriate field, but the item's Id field should not be included. As an example, when creating a Contact you supply the AccountId but not the Id.

Park
jqcoffeyjqcoffey
I'm sorry, but I must be really thickheaded.  I can't seem to make this work.

Perhaps some additional info would be useful.

I have to custom objects broadcasts__c (master), and broadcasts_stats__c (detail).  I have a column in broadcasts_stats__c called "broadcast__c" which (I'm assuming) should have the Id from broadcasts__c.

In my code, I do (psuedo code):

Code:
my $sf_bcasts = $sfconn->do_query("select id,broadcast_id__c from broadcasts__c where broadcast_id__c = $bcast_id",1);

# insert a bunch of sends:
foreach my $send (@$sends) {
$sf_conn->create( type => 'broadcasts_stats__c', 'Contact__c' => $send->{ContactID}, 'broadcast__c' => $sf_bcasts->[0]->{Id} );
}

This fails every time.  I read the previous post about how I should put the Id of the parent object in the appropriate field (which I think I'm doing), but I was unclear on the latter portion of the post, "...but the item's Id field should not be included. As an example, when creating a Contact you supply the AccountId but not the Id."

Any further help would be greatly appreciated.  This is driving me nuts.

Thanks,
Justin
jqcoffeyjqcoffey
I appear to have solved this one... It turns out that (at least through the Perl modules) you have to force the type of reference columns to "xsd:string".  Once I did this, things started populating correctly.  Yeah!

-Justin
SuperfellSuperfell
What is the tns prefix mapped to? can you provide a capture of the request, it sounds like the tns prefix might be mapped to the wrong namespace, and that's causing the server to not be able to find the type.