AnsweredAssumed Answered

record not saving  before_relationship_add logic hook 7.5.0.1 Enterprise

Question asked by KarenV KarenV on Jun 24, 2015
Latest reply on Jun 26, 2015 by KarenV KarenV
I've written the following logic hook: 

  $hook_version =1;
  $hook_array = Array();

  $hook_array['before_relationship_add'] = Array();
  $hook_array['before_relationship_add'][] = Array(
   1, 

   //String to identify the hook
   'hoovers_library_copy',

   //PHP file path
   'custom/Extension/modules/Accounts/Ext/LogicHooks/hoovers_libarary_data_copy.php',

   //The Class method exists
   'hoover_account_class',

   //Method
   'data_copy' 
  );

And now the function itself:

  if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Point');

  class hoover_account_class
  { 
   function data_copy($bean, $event, $arguments)
   {
    if ($bean->load_relationship('accounts_hoovl_hoovers_library_1'))
    {
     $duns = $bean->accounts_hoovl_hoovers_library_1->d_u_n_s_number_c; //pulling data from Hoover's
     $bean->hoov_duns_num_c = $duns; //copying data to Accounts
    }
   }
  }

When I link a Hoover's Library record to Accounts, this field hoov_duns_num should populate with the data from the Hoover's Library record. Instead, the Account record doesn't save. Is there something wrong with my code?

Thank you, 
Karen

Outcomes