AnsweredAssumed Answered

Help debugging set_relationship API call

Question asked by Dennis Haarbrink on May 1, 2014
Latest reply on May 5, 2014 by Dennis Haarbrink
I have created a new module called 'Order' (based on sales module).

I created a new relationship for this module:
name: ord_order_contacts
Primary Module: Order
Type: Many to One
Related Module: Contacts

Now I want to create a relationship between an order and a contact via the API.

So I do the following call:
$set_relationship_parameters = array(
    'session'         => $session_id, //session id
    'module_name'     => 'Contacts', //The name of the module.
    'module_id'       => $contact->id, //The ID of the specified module bean
    'link_field_name' => 'Order', //The relationship name of the linked field from which to relate records.
    'related_ids'     => array( //The list of record ids to relate
        $order->id,
    ),
);
$result = docall('set_relationship', $set_relationship_parameters); 
$session_id contains a valid session identifier
$contact is an object obtained through a get_entry_list call on the Contacts module
$order is a newly created order object, created through a set_entry call

The $result is: 
object(stdClass)#40 (3) {
  ["created"]=>
  int(0)
  ["failed"]=>
  int(1)
  ["deleted"]=>
  int(0)
}
And when I open the order in the application, I can indeed see no relationship to a contact.
So obviously I am doing something wrong, but I can't figure out what. And I really don't know how to debug this issue.

Can somebody please help me creating this relationship?


Outcomes