1. Kayako Download customers: we will continue to develop and support Kayako Download beyond July 2017, alongside the new Kayako for existing customers.

    Find out more.

  2. The forum you are viewing relates to Kayako Classic. If you signed up or upgraded to the new Kayako (after the 4th July 2016), the information in this thread may not apply to you. You can visit the forums for the new Kayako here.

Custom Fields in E-mail notifications

Discussion in 'Installation and setup (Kayako Classic Download)' started by spka, Apr 6, 2014.

  1. spka

    spka Member

    Hi everybody.

    I've created a new custom field (Order number), it works fine when user submits a ticket on the site and displays fine in the helpdesk.

    But in the e-mail notification there is no sign of it, so you can't really tell what's ORDER number is unless you open up helpdesk and check there.

    How can I do proper integration of custom field into email notifications sent to user & staff ?
  2. Gurpreet Singh

    Gurpreet Singh Staff Member

  3. spka

    spka Member

    Yes, I've seen this. But it's quite old..

    Any ETA on this feature to be implemented?

    On the Tickets Confirmation Page I was able to add code to display on the page, but had to tweak some .php files in Kayako.
  4. spka

    spka Member

    Gurpreet Singh

    I heard modification of E-Mail templates should be native in 4.65, I'm on but it seems there is no such functionality, just a generic templates generated from PHP code mostly.

    Can you point me to the right direction?
  5. Tom Lesniak

    Tom Lesniak Established Member


    it looks like the only documentation on the new variables available for modifcation of the email templates was what was noted at the bottom of the 4.65 release note http://wiki.kayako.com/display/DOCS/4.65

    you'd think that they would update their documentation to mention these variables on the templates page of the admin guide.
  6. spka

    spka Member

    So the question is how much time do I need to wait for a new version to arrive or should I do this myself ?
  7. Tom Lesniak

    Tom Lesniak Established Member

    considering that the defect isn't even on their roadmap i'm guessing that it will be a very long time until it is implemented. if you haven't already done so, go to the defect and vote for it. that will help bring it to their attention and get maybe get it resolved.
  8. spka

    spka Member

    Gurpreet Singh

    any update on this feature?
  9. spka

    spka Member

    is there any update on this subject?

    I think this feature should be built-in, otherwise no point in using custom fields at all if you can't embed them in e-mail / templates..
  10. Gary McGrath

    Gary McGrath Staff Member

    Hi there,

    If you are self hosting, you can make this change yourself.

    file: __apps\tickets\library\Notification\class.SWIFT_TicketNotification.php

    Near line 712, look for

    $this->Template->Assign('_ticketNotification', $_templateVariableList['_ticketnotification']);
    Just after this, add the following code:

      $_customFields = array();
      $_SWIFT = SWIFT::GetInstance();
      $_SWIFT->Database->Query("select ".TABLE_PREFIX."customfields.title, ".TABLE_PREFIX."customfieldvalues.fieldvalue ".
      "from ".TABLE_PREFIX."customfieldvalues ".
      "left join ".TABLE_PREFIX."customfields on ".TABLE_PREFIX."customfields.customfieldid = ".TABLE_PREFIX."customfieldvalues.customfieldid ".
      "where ".TABLE_PREFIX."customfieldvalues.typeid = '".$this->Ticket->GetProperty('ticketid')."'");
      while ($_SWIFT->Database->NextRecord()) {
      $_customFields[preg_replace('/\s+/', '', $_SWIFT->Database->Record['title'])] = $_SWIFT->Database->Record['fieldvalue'];
      $this->Template->Assign('_customFields', $_customFields);
    Then you can edit your notificationhtml and text templates, and use this variable to access your custom fields:

    (note you need to type out the name of your custom field without spaces, so if it was "Order Number", then in here you would use "ordernumber")
     My Custom Field value is: <{$_customFields[MyCustomField1]}>
    e.g. My Custom Field value is: <{$_customFields[orderno]}>

    blukr and spka like this.
  11. spka

    spka Member

    Thanks, Gary!

    I'll try this and report back ..
  12. afza123

    afza123 Member

    what about for non selfhosted customers?
  13. Gary McGrath

    Gary McGrath Staff Member

    If you are using the on demand platform, you will not be able to make the above changes I am afraid.

  14. Drew Keller

    Drew Keller Just one person in a world of millions.

    It is not possible with the current version of Kayako.
  15. spka

    spka Member

    Thanks, Gary. It works.

    For localized output you need to create a phrase in languages management for multiple languages and put it's variable into template as well.

    Why this functionality is not in Kayako by default ?
  16. eelloo Support

    eelloo Support New Member

    Hi Gary,

    While using your string of code and editing my mail templates, I came across the following error message while generating a ticket email:

    Undefined index: _customFields (./__swift/cache/d53237737479eb11d859b4f1e10edb04.php:50)

    This notice occured for every customfield I entered in the template, even though I edited the swift-doc just like you described.

    Do you have any suggestions or ideas? Thanks in advance!

    Freek Haagsma
  17. Gurpreet Singh

    Gurpreet Singh Staff Member

  18. eelloo Support

    eelloo Support New Member

    Hi Gurpreet,

    Thanks that's great news, I will update to the latest version (now using 4.71).

    Regards, Freek
  19. Joe Graw

    Joe Graw Established Member

    We are on kayako version 4.90.0. Can you tell me where/how I can include a custom field value inside of a notification alert?


Share This Page