2

I create a module Acquisitions through module builder and now want to make some calculations for some fields.i have no clue how to create a logic hook and where to create this logic hook. please tell me the full path and procedure for this.

Mahi Chopra
  • 103
  • 1
  • 8

4 Answers4

2

I have this very problem. Unfortunately it's not possible because when you you deploy the package in Module Builder, the custom folder gets overwritten and that's exactly where the logic_hook file needs to be.

Even the fact that there is a parameter called "logic_hooks" for that manifest.php install_def, it still doesn't seem to work when the logic_hook you want to add is part of package you are deploying (Yes, that's very annoying).

I posted about this on the sugar forum, you can see more details @: http://www.sugarcrm.com/forums/f6/module-builder-deploy-deletes-my-logic_hook-php-76402/

dkinzer
  • 32,179
  • 12
  • 66
  • 85
  • 1
    Kind of hackish way around it would be to place the logic hook in the global logic hooks file - custom/modules/logic_hooks.php. It is also read any time module hooks are read, and even though it is meant for global hooks, actually you can place there any hook definitions. Downside of it will be that if you put a hook on something like after_save, it will be called for any module type, so inside the hook you will need to check if the bean you've got is "yours" or not. But this probably would allow you to work around MB issue. – StasM Nov 22 '11 at 07:41
  • Yeah, a Sugar support member suggested that as a workaround to me too. – dkinzer Nov 22 '11 at 12:52
  • + that only takes care of the logic_hook file any other customization also gets deleted. – dkinzer Nov 22 '11 at 14:50
  • @StasM know you answered it back in 2011, but sugar 6.5 still seems to have the same "awesome" design. Is there any other way of adding more logic hooks without redeploying the package? Do you know if your solution would work for custom modules? – Robert Sinclair Aug 16 '18 at 02:34
1

See question 4196257 for using logic hooks.

Community
  • 1
  • 1
  • 1
    That question doesn't actually answer the OP's question (at least not how I read it). I'm reading it as "How can I add a logic hook to a package created in Module Builder." While the question your reference only explains how to create a logic hook normally. I have a very similar question, which is whether it's possible to add a logic hook (or other code not available via the Module Builder GUI) so that it gets redeployed in the future. – Anthony Oct 18 '11 at 19:27
  • As far as I know it is not possible to add hooks through the module builder. You can, however, create workflows which basically does the same. But if you need some advanced calculations workflows are usually not sufficient. But if you manually add a logic hook in the files as described, it will also be exported, if you export your custom changes for a module in the module builder. This can than be imported to another Sugar instance. (You can verify the file content by opening the zip file) – Kåre Werner Storgaard Oct 19 '11 at 07:40
0

You can create a logic hook under Custom folder so it will be safe upgrade

/custom/modules//logic_hooks.php

For understanding the logic hook you can follow this link

Logic hook

I hope this Will help you

Abhi Adr
  • 1,264
  • 2
  • 11
  • 27
0

1­Custom/modules/\logic_hooks.php

logic_hooks.php

Descriptions­

1­ ­: Array Index

/Leads/logichooks_class.php ­­:Logic hooks Class File path

ogic_hooks_class­:Logic_hooks Class Name

before_save_method­­:Logic Hooks class Method Name

Logichooks_class.php

id."' "; } ?>
MANI
  • 1
  • 2