Search code examples
phpsugarcrm

Lead assignment notification problems


I'm trying to solve the problem of Lead assignment notifications not working. This question has two parts.

1) What are the possible causes of lead assignment notifications not being sent out, besides those listed in documentation? In my case, the system-level notifications are On and email works well for other uses. Self-assignment has been ruled out.

2) Since the built-in automatic notifications don't work, I created a Process to send an email when a user is assigned to a Lead. It works as intended, but I'm having trouble getting the email to look as desired. In email template, I'd like to have this sentence:

<assigning user name> has assigned a Lead to <assigned user name>.

The <assigning user> can be the currently logged in user. How can I create a custom variable that will insert the name of the currently logged in user into an email template? Is there another way to insert the <assigning user name>?


Solution

  • 1)

    Do you happen to save/reassign those Leads using code?

    Be aware of the function argument of SugarBean->save():

    /*       
     * @param boolean $check_notify Optional, default false, if set to true assignee of the record is notified via email.
     */                                                                          
    public function save($check_notify = false)
    

    As far as I understand, calls to the functions won't generate notifications unless you call it similar to this:

    $myLeadBean->save(true);
    

    Other than that I have no idea what could be going wrong. However, when it comes to debugging mails, make sure to first check your spam folders and, if possible, the mail server logs.
    If the lost mails aren't there, set log level to Info in Sugar -> Administration -> System settings and maybe you can see if and how Sugar attempts to send those mails.
    Note: This will produce a lot of log output, so try to test it on an idle test instance and reproduce the problem with as few requests as possible (minimizing log noise).
    Make sure to set back your log level to fatal or error after debugging the problem.


    2)

    I couldn't test this myself yet and I don't know how exactly templates are used in your process, but did you check those used in the default templates yet?

    ./include/language/en_us.notify_template.html¹

    {ASSIGNER} has assigned a Note to {ASSIGNED_USER}.

    For seeing how those variables gets assigned, see ./data/SugarBean.php or ./include/workflow/alert_utils.php²

    $xtpl->assign("ASSIGNER", $current_user->name);



    ¹ found with command: find . -name 'en_us.*' -exec grep -i '{.*user' {} +

    ² found with command: find . -name '*.php' -exec grep ASSIGNER {} +