Results 1 to 3 of 3

Thread: Custom calculated field for e-mail replacement

  1. #1
    wprice99 Guest

    Default Custom calculated field for e-mail replacement

    I'm looking to add a customer non-database field to the meetings module, for e-mail template replacement reasons.

    At the moment, if I use $meeting_date_start in the e-mail template, then the date will always be represented as something like 31/12/2013 10:30. In order to have more friendly e-mails, it would be good to be able to specify the template text as something like:

    "We are pleased to confirm... your meeting at 10:30 on 31 December 2013"

    instead of having to have

    "We are pleased to confirm... your meeting on 31/12/2013 10:30"

    While I can always update the internals of the code, what I'm thinking will be a sensible option will be to introduce two extra fields to the meetings module, which are non-database fields, and calculated to produce 'friendly' date-only and time-only text, which can be used with replacement variables, e.g. $meeting_friendly_date, $meeting_friendly_time.

    I'm not entirely sure whether this would be the best option, or whether there is an alternative. Some suggestions as to how to do this (or an equivalent) would be appreciated.

    SugarCE 6.5.15.

  2. #2
    dkallish@sugarcrm.com Guest

    Default Re: Custom calculated field for e-mail replacement

    Hello,

    The 'Save & Send Invites' button sends a hard-coded invitation template. You can review the contents of that template by looking at:

    ./include/language/en_us.notify_template.html

    The Meetings module section is lines 106 through 132. Attempts to change any of the syntax'd values, such as {MEETING_STARTDATE}, result in that value just not being populated at all in the received email. This is because these values are defined in the following file:

    ./modules/Meetings/Meeting.php

    Reviewing this file, I found the variables to be stored between lines 548 and 573:

    $xtpl->assign("MEETING_TO", $meeting->current_notify_user->new_assigned_user_name);
    $xtpl->assign("MEETING_SUBJECT", trim($meeting->name));
    $xtpl->assign("MEETING_STATUS",(isset($meeting->status)? $app_list_strings['meeting_status_dom'][$meeting->status]:""));
    $typekey = strtolower($meeting->type);
    if(isset($meeting->type)) {
    if(!empty($app_list_strings['eapm_list'][$typekey])) {
    $typestring = $app_list_strings['eapm_list'][$typekey];
    } else {
    $typestring = $app_list_strings['meeting_type_dom'][$meeting->type];
    }
    }
    $xtpl->assign("MEETING_TYPE", isset($meeting->type)? $typestring:"");
    $startdate = $timedate->fromDb($meeting->date_start);
    $xtpl->assign("MEETING_STARTDATE", $timedate->asUser($startdate, $notifyUser)." ".TimeDate::userTimezoneSuffix($startdate, $notifyUser));
    $enddate = $timedate->fromDb($meeting->date_end);
    $xtpl->assign("MEETING_ENDDATE", $timedate->asUser($enddate, $notifyUser)." ".TimeDate::userTimezoneSuffix($enddate, $notifyUser));
    $xtpl->assign("MEETING_HOURS", $meeting->duration_hours);
    $xtpl->assign("MEETING_MINUTES", $meeting->duration_minutes);
    $xtpl->assign("MEETING_DESCRIPTION", $meeting->description);
    if ( !empty($meeting->join_url) ) {
    $xtpl->assign('MEETING_URL', $meeting->join_url);
    $xtpl->parse('Meeting.Meeting_External_API');
    }

    return $xtpl;
    }

    The $startdate and $enddate variables are where you would need to make changes in order to implement your desired functionality. Modifying this file directly isn't necessarily recommended, since it is a core file and doing so is not upgrade safe, but it's a starting point. I'll continue working on this and try to present an upgrade safe customization that meets your requirements, but I wanted to present this information so you can at least get a feel for how the Invitation Template is built.

    Kind regards,

    Dan Kallish
    SugarCRM Technical Support Engineer

  3. #3
    wprice99 Guest

    Default Re: Custom calculated field for e-mail replacement

    Thank you for the above. I'll be interested to see what upgrade-safe customizations you can come up with.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Custom Calculated Field in Listview
    By BubbaFL in forum Developer Help
    Replies: 5
    Last Post: 2013-08-11, 06:47 PM
  2. Custom Calculated Field
    By andywest in forum Developer Help
    Replies: 8
    Last Post: 2012-01-10, 01:50 PM
  3. Calculated field in custom module
    By sowjanya_m in forum Developer Help
    Replies: 8
    Last Post: 2011-03-31, 11:29 AM
  4. Custom Action / Calculated Field
    By craig_lang in forum Developer Help
    Replies: 4
    Last Post: 2011-02-09, 01:38 PM
  5. Custom readonly calculated field
    By vishaldpatel in forum Developer Help
    Replies: 2
    Last Post: 2011-02-01, 10:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •