Having trouble copying data from related field in a logic hook.
Here’s the logichook.php code:
<?php $hook_version = 1; $hook_array = Array(); $hook_array['before_save'] = Array(); $hook_array['before_save'][] = Array(1, 'Produkt von Contract übernehmen', 'custom/modules/Documents/customWF.php','CopyFields','copyProdukte'); ?>Here’s the customWF.php code:
<?php if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class CopyFields { function copyProdukte($bean, $event) { $rel_contract = new AOS_Contracts(); // initiate Contract object $rel_contract->retrieve($bean->aos_contracts_id); // retrieve related contract field data $bean->description = $rel_contract->description; // doesn't work! // $bean->description = 'aaa'; // tested: works } // end function copyProdukte } // end class CopyFields ?>The customWF.php code is definitely being run, but I can’t get any data from the related Contract to be copied into the linked document.
I tried both
$rel_contract->retrieve($bean->contracts_id);
and
$rel_contract->retrieve($bean->aos_contracts_id);
(both could be found in /cache/modules/Documents/Documentvardefs.php)