AnsweredAssumed Answered

Relate a Call to both the Contact and Account with the Bean

Question asked by Merrick Dennis on Mar 31, 2014
Latest reply on Jun 5, 2014 by Francesca Shiekh
SugarCRM 6.5.x Pro

I am attempting to use the bean via PHP to log certain call records automatically and am able to successfully create calls under Accounts and Leads and have them associated correctly.

This is my function that I'm using to log the call and it works fine under Accounts, Contacts and Leads, but when done under a Contact, it only displays the call record within the History subpanel of the Account, and not the Contact.  Furthermore, the "Contact" column does not display the contact name.

function createCall($obc_id, $record_id, $user_id, $datetime, $module) {     
  $newCall = BeanFactory::newBean('Calls');
  $newCall->id = $obc_id;
  $newCall->new_with_id = True;
  $newCall->assigned_user_id = $user_id;
  $newCall->parent_id = $record_id;
  $newCall->created_by_link = $user_id;
  $newCall->direction = $this->direction;
  $newCall->tasktype_c = $this->taskType;
  $newCall->parent_type = $module;
  $newCall->name = $this->recordName;
  $updateCall = BeanFactory::getBean('Calls', $obc_id);
  $updateCall->created_by = $user_id;
  $updateCall->date_start = $datetime; 

When logging a call manually (through the UI) under a contact record that is associated with an account, the record will display in the history subpanel of both the contact that it was logged under, as well as the account that the contact is associated with.  When viewing the actual account record, the "Contact" column in the history subpanel will display the name of the contact as well.  See the screenshot below as an example of the call record displaying in the history subpanel of the account:

How can I achieve this by using the bean?

Thanks in advance!