CASE_NUMBER is not available to Smarty Template in Cases Module , Notify Method

Running a clean copy of 7.11.7.

The code below in case.php never finds the case number.

public function set_notification_body($xtpl, $case)
    {

        global $app_list_strings;
        $GLOBALS['log']->debug("debugging new case");
        $xtpl->assign('CASE_NUMBER', $case->case_number);
        $xtpl->assign('CASE_SUBJECT', $case->name );
        if(isset($case->case_number)){
            $GLOBALS['log']->debug("found case number");
        }else{
            $GLOBALS['log']->debug("case number not found");

            //look up case
        }
        $xtpl->assign(
            'CASE_PRIORITY',
            (isset($case->priority) ? $app_list_strings['case_priority_dom'][$case->priority] : '')
        );
        $xtpl->assign('CASE_STATUS', (isset($case->status) ? $app_list_strings['case_status_dom'][$case->status] : ''));
        $xtpl->assign('CASE_DESCRIPTION', $case->description);

        return $xtpl;
    }

This bug is on GitHub as well , hoping for some new eyes on this.

https://github.com/salesagility/SuiteCRM/issues/8113

There are two bags at the same time.

  1. For all records. You should edit include/language/en_us.notify_template.html . Find block from “” to “” and insert line: “Number: {CASE_NUMBER}
    ” I am sure that you understand where to insert.
  2. For new records. When you create new record in Case module this field is empty and the field case_number isn’t filled in editview form. This field is marked as AUTO_INCREMENT in database and it fills in at the moment of data saving into the database. When the function set_notification_body works the data from the editview form was not saved in the database yet. I can present modified function set_notification_body in class aCase:
   
 public function set_notification_body($xtpl, $case)
    {
        global $app_list_strings;
/* Start of added code */
        if (empty($case->case_number) && isset($case->id) && !empty(isset($case->id))){
            $q='SELECT max(case_number) FROM cases';
            $r = $case->db->getOne($q);
            $case->case_number = $r + 1;
        }
/* End of added code */
        $xtpl->assign('CASE_NUMBER', $case->case_number);
        $xtpl->assign('CASE_SUBJECT', $case->name);
        $xtpl->assign(
            'CASE_PRIORITY',
            (isset($case->priority) ? $app_list_strings['case_priority_dom'][$case->priority] : '')
        );
        $xtpl->assign('CASE_STATUS', (isset($case->status) ? $app_list_strings['case_status_dom'][$case->status] : ''));
        $xtpl->assign('CASE_DESCRIPTION', $case->description);

        return $xtpl;
    }
1 Like

Thanks, this is a great start.