Working with timezones in BPM E-mail templates

Hi, 

for a customer we have a BPM workflow that uses a e-mail template which contains a date/time field from a certain record. The only purpose of the BPM is to send out a notification to a specified contact, in the record of the custom module just created, The problem I'm facing is that the date/time that is mentioned in the field is not correct. It is shown as the UTC version of the date/time. I would have expected to be converted to the timezone from the person who is sending out the mail (or the from the person that created the record in the first place). 

According to Sugar that is a known issue and a enhancement request is created for it. Is there someone in the club who faces the same issue and has already solved it? 

  • Hi , I had to customize BPM once and it was fairly straightforward.

    I did a quick check in the code and the issue that you mention comes from modules/pmse_Inbox/engine/PMSEHandlers/PMSEBeanHandler.php, function mergingTemplate

    Here is the code that substitutes the UTC date firectly from DB:

    // Handle date/datetime, and boolean, field types
    // to maintain proper UTC values
    if (in_array($def['type'], ['datetime', 'datetimecombo']) && !empty($newBean->fetched_row[$fieldName])) {
    $value = $newBean->fetched_row[$fieldName];
    }

    So all we have to do is to customize the PMSEBeanHandler, and thankfully the mergingTemplate function is public:

    The PMSE code indeed allows custom classes, so once we create custom/modules/pmse_Inbox/engine/PMSEHandlers/CustomPMSEBeanHandler.php and extend the mergingTemplate, we probably have two options:

    1. Copy the entire mergingTemplate function, modify the part where it uses fetched_row

    2. Another option is to just call parent::mergingTemplate and detect if there are dates, and apply an override in the returned value.

    Hope it helps!