Why am I getting HTTP: 500 Internal Server Error when I am trying to use after_retrieve?

I am trying to use logic hook 'after_retrieve', but I keep getting a 500 Internal Server Error when it is trying to load records into the subpanel.

It happens whether I have something called by after_retrieve or even just set it as an empty array.

I even tried 'after_fetch_query', but that never runs anything.

Fullscreen
1
2
$hook_array{'after_retrieve'] = Array();
$hook_array['after_retrieve'] = Array(11, "Check Whether to Highlight Title","custom/Resources/logic_hooks/Courses_Logic_Hooks.php", "Courses_Logic_Hooks", "setAlertField",);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Do you see any error into either apache or php error_log?

    Can you share content of your after_retrieve logic hook?

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • I don't see anything in the error log, sugarcrm or apache.  I now it has nothing to do with the code, because just putting the following in by itself makes it error.

    Fullscreen
    1
    $hook_array{'after_retrieve'] = Array();
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Course Logic Hook

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    <?php
    global $db, $sugar_config;
    class Courses_Logic_Hooks {
    //Set field: name
    public function Set_Course_Name(&$focus, $action, $args = array())
    {
    $focus->name = $focus->course_name_c;
    }
    //Set field: curriculum_type
    //No longer used, but kept for reference. Now replaced via /custom/extension/lev_courses/vardefs/sugarfield_curriculum_type.php
    public function Set_Curriculum_Type(&$focus, $action, $args = array())
    {
    require_once('modules/Lev_Course_Catalog/Lev_Course_Catalog.php');
    $course_catalog = new Lev_Course_Catalog();
    $ctype =$course_catalog->retrieve($focus->lev_course_catalog_id_c);
    $focus->curriculum_type = preg_replace('/[_]/', ' ', $ctype->curriculum_type);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • 500 errors are almost always syntax errors, you have an error on line 1, you are opening a curly bracket instead of a square bracket :)

    $hook_array{'after_retrieve'] = Array();

    should be 

    $hook_array['after_retrieve'] = Array();

    FrancescaS

  • good eye !!!

    Rodrigo Manara

    Sr. Developer