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..  

  • I should correct myself.  The logic hooks for course name and curriculum Type were running, but blanking everything out.  I found  that I needed to replace the following even though there were no known permission issues.

    $ctype = BeanFactory::getBean('Lev_Course_Catalog', $focus->lev_course_catalog_id_c); 


    $ctype = BeanFactory::getBean('Lev_Course_Catalog', $focus->lev_course_catalog_id_c, array('disable_row_level_security' => true));

  • BeanFactory::getBean('<module>', $id) will give you a new empty Bean if that id does not exist.

    Whenever you know the ID I recommend you use BeanFactory::retrieveBean('<module>', $id)

    this will give you the actual bean with that ID or nothing at all.

    Then you can add a check in your code to make sure that the bean was actually retrieved, for example:

    if (!empty ($focus->lev_course_catalog_id_c)){
      $LevBean = BeanFactory::retrieveBean('Lev_Course_Catalog', $focus->lev_course_catalog_id_c);
        //You've got the bean!
        //No record found with that ID
      //you didn't have an ID to start with
      $GLOBALS['log']->fatal("ERROR: $lev_course_catalog_id_c is empty"));

  • It is creating a new bean.  The weird thing is I can  reach curriculum Type, but can reach the name.

    Set_Curriculum_Type is working, but Set_Course_Name is not working.

    If I use disable_row_level_security it works, but that is not acceptable by my boss.

    The user has access to the name normally, in fact I am testing with a regular user with no role, but I can't access name from the code.


    public function Set_Curriculum_Type(&$focus, $action, $args = array())
    $ctype = BeanFactory::getBean('Lev_Course_Catalog', $focus->lev_course_catalog_id_c);
    // $ctype = BeanFactory::getBean('Lev_Course_Catalog', $focus->lev_course_catalog_id_c, array('disable_row_level_security' => true));

    $focus->curriculum_type = preg_replace('/[_]/', ' ', $ctype->curriculum_type_c);
    $GLOBALS['log']->fatal('Set_Curriculum_Type run $focus->curriculum_type = ' . $focus->curriculum_type);

    //Set field: name
    public function Set_Course_Name(&$focus, $action, $args = array())
    // $associated_CourseCatBean = BeanFactory::getBean('Lev_Course_Catalog', $focus->lev_course_catalog_id_c, array('disable_row_level_security' => true));
    $associated_CourseCatBean = BeanFactory::getBean('Lev_Course_Catalog', $focus->lev_course_catalog_id_c);
    $focus->name = $associated_CourseCatBean->name;
    $GLOBALS['log']->fatal('Set_Course_Name run $focus->name = ' . $focus->name);
    $GLOBALS['log']->fatal(print_r($associated_CourseCatBean, true));
    $GLOBALS['log']->fatal('ERROR: $focus->lev_course_catalog_id_c is empty');


  • You still use get without any check for valid beans. Blanking out is a real indicator for the creation of a new and empty bean. Try retrieveBean instead.

    I do not understand why a logic_hook should not be allowed to use the disable_row_level_security' => true paramter When it has to work on all data it needs access to all data. And it looks that you have special access rights on this module.

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

  • It does work with disable_row_level_security => true

Reply Children
No Data