What are reason logic hooks would work for Admin but not regular users?

I have recently started our CRM from scratch and created packages for all the customizations.   We have gone to production and realized that the logic hooks are not being done when the user is not an admin.

Please help..  

  • can you upload your package or a stub of your package?

  • Can you share with us the code so we can see what is going on. Maybe you hit an issue with retrieving beans that a user doesn't have access to for instance

  • The most likely answer is roles and/or teams in some way.  Would need to see an example of the code to be sure.

  • It's probably bug 83097 in Sugar.

  • Amy, 

    Could you please clarify whether you refer to Web Logic Hooks or regular Logic Hooks?

    I would suggest making a test.

    Here is a very simple Logic Hook configured in Logic Builder from the scratch - it creates a new Note for the Account on Account save
    It works for any user and Sugar - Cloud or on-premise, starting version 7.2 and for the regular user with regular access to both Account and Notes modules.

    here is the zip package for  this logic hook configuration:

    You may install zip with Module Loader then try out saving any Account with regular user credentials - if you find a new Note for that account on account saved, then Logic Hooks are definitely operational on your instance.

    When the test is done, you can uninstall zip with Module Loader.

    Best Regards,
    Dmytro Chupylka

    We make work in Sugar CRM system faster, more convenient and efficient

  • A coded logic_hook runs in the context of the current user. If the current user has no access to certain modules and the logic_hook tries to access one of these modules, you get an error.

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    SugarCRM Deutschland GmbH

  • Not sure about this. I think that it will fail silently? 

    $record = BeanFactory::retrieveBean('Accounts','<id you are not allowed to see>');

    The factory will not throw an exception but will simply return 'null'. And you don't check that correct you will get the error. Otherwise you don't. But maybe i'm wrong. In any case if the error is thrown users should get an error or something similar?

  • That seems to differ from version to version. I just tested the 10.3 and got the result that a user who is not allowed to see the businesscenter module sees it on the recordview of an account. That's very new for me.

    In old versions the hooks just stopped execution without any feedback.

    And I think it was a version 9 where I got hard error 500 messages when some access went wrong.

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    SugarCRM Deutschland GmbH

  • CE_LogicHooks.zip

    The user has permission edit the fields needed, except they can't import.

    I am working with regular logic hooks.

    Technically  they are all "Not Set" which defaults to Enabled..

  • Are none of these working?  Or is it just one of them? 

    Can you add $GLOBALS['log']->fatal('@Start ...') at the top of every function?

    Could it be because you are executing RAW sql that this is causing issues when a 'normal' user is executing the logic hook?

    In any case couple of enhancements. :

    1) You can put logic hook classes anywhere you like but I got used toadd them to custom/Extension/modules/<module>/Ext/Logic/. This way you have your logic_hooks.php in custom/Extension/modules/<module>/Ext/LogicHooks/logic_hooks.php and your logic file in the same data structure

    2) Start using SugarQuery instead of raw SQL queries.