Pliz, guide me in logic hook

Hello, all.

Pease guide me in Logik hook.I try to achive this: take tel number from Contacts to field in Cusom module.
But it nothing to do, guide me, plz.

Fields:
Contact - related from Custom_sale to Contcats (standar module);
phone_mobile - Contacts field, mobilephone number;
tel_num - Custom_sale Phone Field, need to fill from Contacts phone_mobile

Thanks for help.

Hook file:

<?php $hook_version = 1; $hook_array = Array(); $hook_array['before_save'] = Array(); $hook_array['before_save'][] = Array( 1, 'unitcost', 'custom/Extension/modules/Custom_Sale/unitel.php', 'teltransf', 'telnum' ); unitel.php <?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class teltransf { function telnum ($bean, $event, $arguments) /* test hook contact*/ $needcontact=$bean->Contact; $contactBean=new contact(); $contactBean->load_relationship('contacts'); $contactBean->retrieve($needcontact); $contactBean=$bean->Contacts->phone_mobile; $bean->tel_num=$contactBean; } } ?>

You’re missing the type of hook, which needs to be passed as the argument to the array.

Here is an example:


$hook_array['before_save'] = Array(); 
$hook_array['before_save'][] = Array(11, 'Save case events', 'modules/AOP_Case_Events/CaseEventsHook.php','CaseEventsHook', 'saveUpdate'); 

That ā€œbefore_saveā€ tells SuiteCRM which event triggers the hook. You don’t have anything there!

See the part about ā€œmodule hooksā€ here to get a full lit of possible values:
http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_6.7/Module_Framework/Logic_Hooks/index.html

Good luck.

1 Like

Thanks i’m really missing ā€˜before_save’.
Hook is now ā€œfireā€ but still do nothing (but dont make error :slight_smile: ).
PHP file dont work - i dont have big knowledge in programing.
Plz guide what’s wrong in code.
Thanks.

I’m sorry, your code is a mess, it is beyond any possibility of me helping you : - )

I suggest buying and reading Jim Mackin’s eBook, SuiteCRM for Developers.

You can also try looking for more useful example on Google…

Thanks, I get book :slight_smile:
It`s working !