1

I am working in the hook. When I create a record from subpanel it doesn't trigger the hook. But when I use link existing record the hook is executing. Which hook should we use when create from a subpanel.

$hook_array['after_relationship_add'][] = array(
    1,
    'after relationship hook',
    'custom/modules/Records/Hooks/LinkedRecord.php',
    'Records_Hooks_LinkedRecord',
    'linkedRecords',
);

Community Link: https://community.sugarcrm.com/message/94290-subpanel-create-dosent-trigger-hook

Star
  • 3,222
  • 5
  • 32
  • 48
DonOfDen
  • 3,968
  • 11
  • 62
  • 112
  • 1
    What kind of code are you running when the relationship is added? In other words, in what context is your hook? Is this hook on the parent, or the child? – Reisclef Jul 28 '17 at 21:43
  • 1
    I found the solution @Reisclef will post the answer. The hook should be create module then the display module. – DonOfDen Jul 29 '17 at 16:55

1 Answers1

1

If you want to trigger your code on creation of record then you will need to use after_save and before_save logic hooks. See this link for further details: http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_6.5/Module_Framework/Logic_Hooks/Module_Hooks/

Last but not least, create from module or sub-panel trigger same hooks (after and before) so no difference in creation from sub-panel and module.

Hopefully provided documentation is clear enough.

Star
  • 3,222
  • 5
  • 32
  • 48
  • 1
    I found the solution, will post the answer. The hook should be in create module then the display module – DonOfDen Jul 31 '17 at 08:39
  • 2
    Yes you are right about your mentioned point as well. You know if you want to trigger hook then module should be enabled so that sugar can use it. – Star Jul 31 '17 at 09:22