Search code examples
phpsugarcrmsuitecrm

Copy field to another field in same module - suitecrm


When creating a new record i am trying to copy the value from a relate field to the name field of my custom module. To do this i am using the following logic_hook:

<?php
// Do not store anything in this file that is not part of the array or the hook version. This file will
// be automatically rebuilt in the future.
$hook_version = 1;
$hook_array = Array();
// position, file, function
$hook_array['before_save'] = Array(); 
$hook_array['before_save'][] = Array(1, 'Value from one field to another', 'custom/modules/chan_channelpartner/textcopy.php', 'textcopy','textcopy');

?>

and here is my textcopy.php file:

<?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    class textcopy
    {
        function textcopy($bean, $event, $arguments)
        {
            $bean->name = $bean->namenew_c;
        }
}  

?>

When running this file my browser returns a white screen with the following text:

name = $bean->namenew_c; } } ?>

Solution

  • Check your Apache/PHP logs for errors. Something should pop up there.