Previous Topic

Book Contents

Book Index

Next Topic

Used Email Functions

In step 4 of the notification creation wizard it is possible to use email functions. Note that the grayed out functions which appear on the wizard page are just textual examples and cannot be copied or edited. They serve as examples of what functions can be used and what their syntax is.

Available functions:

  • <%emf.getValue("attr")%>

    Function <%emf.getValue("attr")%> retrieves value of the specified attribute ("attr") of the business object for which the send email action is called (i.e. the object specified on the 'Object Type' Tab).
    Often a structured attribute will be used, as depicted in the 'Email Template Tab' topic, where attribute 'personrequestedby.email' was used to insert the value of 'email' attribute of the 'person' object referenced as 'personrequestedby' by the ticket for which the Send Email action is called.

  • <%emf.getValueAndAppendComma("attr")%>

    Function retrieves value of the specified attribute ("attr") and appends a comma after the value. The intended use is insertion of multiple email addresses.
    If you had N recipients in one address field, you would use this function for first (N-1) addresses and then use <%emf.getValue("attrb")%> for the last address.
    In case of 2 recipients, it could look like this:
    <%emf.getValueAndAppendComma("personrequestedby")%> <%emf.getValue("personrequestedfor")%>

    The result would be (for example):

    john@test.com, mary@test.com

    Notice that there is no comma between the functions - it is added by the function <%emf.getValueAndAppendComma("attrb")%>
    If there was no email defined for personrequestedby, the function would return an empty string and the result would be (for example):
    mary@test.com

  • emf.getValueOf("boname","attr")

    Function <%emf.getValueOf("boParamName","attr")%> is capable of retrieving attribute values from arbitrary objects, i.e. objects other than the one for which the send email action is called.

    Parameter "boParamName" is code identifying objects in hashmap 'dynamicParamsBag'. Standard readily available hashmap codes are 'bo', ' boMailObject', 'escTypeLevel and 'boEmailBody' (listed as 'Parameters' on the 'Info' tab). Use one of these parameters in place of 'boParamName' in <%emf.getValueOf("boParamName","attr")%> to identify the corresponding object. In place of 'attr', specify the object attribute whose value is to be retrieved by the function.

    We can see that 'emf.getValue("attr")' function is equivalent to 'emf.getValueOf("boParamName","attr")' where 'boParamName' = 'bo'.

  • <%emf.getCollectionValue("relAttrName","condition","sorting","columns","format","separator")%>

    Function retrieves values from objects referenced (by the object type for which the Send Email action is called) as a collection attribute. For example, it could insert a list of selected attributes of individual ticket descriptions belonging to the ticket the email is called for.

    • relAttrName

      Name of the relation attribute containing a collection of objects

    • condition

      Condition for filtering of the collection, standard syntax used e.g. in Valuemation full search applies.

      E.g.: <%emf.getCollectionValue("descriptions","statementtype.statementtype=='Work History'","descno descending","descno,dateCreate,statementtype.statementtype,tckShorttext","#%s, %s, %s, %s","\n")%>

    • sorting

      List of attributes used for sorting of the collection. Ascending sort order is default, for descending order put the word "descending" after the attribute name, e.g.: "lastname descending,firstname".

    • columns

      List of referenced objects' attributes returned by this function (Note: do not use spaces in the attribute list!)

      e.g. "lastname,firstname,email"

    • format

      Formatting string for the output.

      - each individual attribute (specified in 'columns') in the output must be represented with one %s

      - for new line use \n, for tabulator use \t

      Example: list of emails sent for a ticket:
      <%emf.getCollectionValue("descriptions.personcreate", "", "lastname descending,firstname", "lastname,firstname,email", "%s, %s\temail=%s\n","")%>
      The result might look like this:
      Lennon, John email=john@test.com
      Kay, Mary email=mary@test.com

    • separator

      String used as line separator. For example, instead of using \n as part of the formatting string, \n could be used as the separator parameter. In such case, _\n would be applied only to the first (N-1) lines.

      Separator could ideally be used to separate individual lines of the collection in some pseudo-graphical way such as multiple dashes. E.g.:

      <%emf.getCollectionValue("descriptions.personcreate", "", "lastname descending,firstname", "lastname,firstname,email", "%s, %s\temail=%s","\n-----\n")%>

      Would result in:

      Lennon, John email=john@test.com

      -----
      Kay, Mary email=mary@test.com

  • <%emf.getDatetimeValue("attr","format")%>

    Function used to get value from a datetime attribute. Same as <%emf.getValue("attr")%> with added ability to specify datetime format.

    Default datetime format used by email templates is "dd.MM.yyyy HH:mm". Function <%emf.getDatetimeValue("attr","format")%> makes it possible to enter datetime value formatted differently.

    For example, <%emf.getDatetimeValue("datecreated","yyyy.MM.dd 'at' HH:mm")%> would give e.g. 2012.12.21 at 06:30

  • <%emf.setDatetimeFormat("format")%>

    Default datetime format used by email templates is "dd.MM.yyyy HH:mm". Function <%emf.setDatetimeFormat("format")%> can be used to change this default datetime format so that all datetime values in the email are custom-formatted without the need to change their formatting (from the default one) using function <%emf.getDatetimeValue("attr","format")%>.

    This makes it possible to insert datetime values using other "datetime non-specific" functions (emf.getValue... / emf.getCollectionValue...) and still have the inserted datetime values custom-formatted.

    To use the <%emf.setDatetimeFormat("format")%> function, just insert the function (function does not return any values) before other value-returning functions. It is enough to insert the setDatetimeFormat function once, it will influence all datetime values that follow.

  • %emf.getParam("paramName")%

    Function <%emf.getParam("paramName")%> is similar to <%emf.getValueOf("boParamName","attr")%>. The difference is that the objects in hashmap 'dynamicParamsBag' are identified by a plain value (string, numeral) instead of a business object - attribute combination.

See Also

Notifications

Notifications Catalog

Notification Editor

Creating a Notification