HOWTO: Customize the assignment notifications for a custom module.

sugarcrmdevelopers —  May 10, 2011 — 22 Comments

I came across a great question in the forums this week, where the poster had created a custom module but wanted to customize the assignment notification email that goes out to the user once a record is assigned to them. By default, we have a rather generic one, but two quick and easy modifications allow changing the email content.

First off, we need to define the method set_notification_body() in our custom module’s bean class. This method will allow you to specify template fields for the email template ( my_module is the name of your module in the code example below ).

Next, we need to copy the default include/language/en_us.notify_template.html template file to custom/include/language/en_us.notify_template.html to make our changes to the file in an upgrade-safe way. At the end of this file, you’ll want to add what your module’s email template should be ( my_module is the name of your module in the code example below ).

With that, the next time you assign a record to a user in the module, it will use the new template you defined.

 

22 responses to HOWTO: Customize the assignment notifications for a custom module.

  1. 

    The only problem with this, is that you cannot customise the set_notification_body on an existing bean (eg: Cases) if you want to display different fields (eg: custom fields).
    You can only customise the way fields are displayed on the template, not the real content of the email.

    • 

      Yes, you are correct with not being able to customize set_notification_body() on OOTB modules. We are working on a way to allow upgrade-safe customizations to the bean files for a future version of Sugar, so stay tuned.

      • 

        This would be actually awesome! Great news!This is something I’m used to do with Codeigniter framework (extending the main object concept, with custom ones) and the framework will load the custom one if it exists, instead of the core one.Can’t wait to see that in SugarCRM!

        • 

          Is the function designed to send the assignment email for the custom module? When I assign a user within my custom module it does not send an email. When I try to alter the custom modules.php file I receive a fatal error (Cannot redeclare class). I put the first file you mentioned in the  crm/modules/a1646_sale.php file. Where a1646_sale is my custom module.

          Should I have added this php function under my custom/module/a1646_sale.php file?

          Thanks for the blog and your help

      • 

        Is the function designed to send the assignment email for the custom module? When I assign a user within my custom module it does not send an email. When I try to alter the custom modules.php file I receive a fatal error (Cannot redeclare class). I put the first file you mentioned in the  crm/modules/a1646_sale.php file. Where a1646_sale is my custom module.

        Should I have added this php function under my custom/module/a1646_sale.php file?

        Thanks for the blog and your help ********************Sorry i posted the first reply to the wrong person.***********************

  2. 

    Any update on the ability to customize set_notification_body() on OOTB modules?

    Thanks!!!

  3. 

    Hi,

    I have to change the formating of notification email to RTL.Is it possible in sugarcrm CE 5.5.4.My application is bilingual ie in English and in Farsi.
    I have to make this for Farsi text.

    Please help me!

    Thanks,

    Manish

  4. 

    Hi there,

    On plateform: SugarCRM 6.5.15 CE and working on French using Carrenet pack.

    Regarding custom notifications on standard module such as Opportunities – Case – Meeting

    when assigning an opportunity to a user, I am looking to add the account name information to the notification which being sent.

    To do so from what I read:
    (1) I’ve modified the fr_FR.notify_template.html file to add ACCOUNT_NAME under the opportunity “section”

    (2) and modified the et_notification_body on the Opportunity.php file found under modules/Opporunities with the following :
    $xtpl->assign(“ACCOUNT_NAME”, $account->name)

    But when generating a new notification the label Account is ok but the field Account_Name doesn’t show up ??

    Could you please give me some quick helps ?

    Many thanks,

    Kindly,
    Alex

  5. 

    I did that. But how can i configure the notification to display information of a parent object like :

    – To show within an opportunity notification, fields related to the associated account.

    – To show within a meeting notification, fields related to billing or shipping adresses from the related account or information from an opportunity object

    From the set notification body funcion i cannot find a way of defining multiple beans. Is it possible ?

    Many thanks,
    fedo

  6. 
    Saad Shahid Ghouri June 16, 2014 at 2:45 am

    Hi

    How can I add html in assignment notification email (include/language/en_us.notify_template.html). If i add html it shows as it is the html tags in email body.
    I want to format the email body
    Can anyone please help?

    Thanks

  7. 

    I am trying to customize and add CaseNumber in email notification body of case but no Success..
    Is it possible..?
    if yes how can i do that..?

Trackbacks and Pingbacks:

  1. Custom email sent from custom module - SugarCRM Forums - August 31, 2011

    […] […]

  2. Modify Cases autogenerated e-mail in CE - November 2, 2012

    […] […]

  3. a case has been assigned to {ASSIGNED_USER}. add users mobile - February 28, 2013

    […] […]

  4. Add logo to email notifications? - April 26, 2013

    […] […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s