Skip to main content
1-Visitor
June 26, 2013
Solved

substitution-keywords for userdata in javamail.js?

  • June 26, 2013
  • 1 reply
  • 1268 views

Hi @all,

if i want to send a notification by a trigger i'm using the javamail.js. In the trigger-config i can write a mail-body and in this text i can use some keywords, which are pointing to item-based informations. Example: <%id%> shows the item-ID, <%fieldname%> shows the entry of the field "fieldname". If this field is a userfield i will get the username in my mail. Is there a way to get the full Name instead the username by such a keyword?

Thanks and kind regards, Jens

    Best answer by matt_giltaji

    Hi Jens,

    Do you mean javamail.js or emailAdvanced.js? I don't see any message parameters in javamail.js, so it might be that your version is already customized.

    If you mean emailAdvanced.js, you could customize the getFormattedMessageBody() function to pull the full name for user fields with something like the below (after you've identified the field as a User field and that you want the full name):

    strUserName = getFieldValue(forBody, fieldName, false);

    beanDomainUser = serverBean.getUserBean(strUserName);

    stringBuilder.append(beanDomainUser.getFullName());

    You may need to change around some of the variable names, we have refactored our code to improve the readability of emailAdvanced.js, so i don't have the original version close at hand. You may also want to add error handling/ check if the username is valid before using it, etc.

    Hope that helps,

    Matt

    1 reply

    1-Visitor
    June 26, 2013

    Hi Jens,

    Do you mean javamail.js or emailAdvanced.js? I don't see any message parameters in javamail.js, so it might be that your version is already customized.

    If you mean emailAdvanced.js, you could customize the getFormattedMessageBody() function to pull the full name for user fields with something like the below (after you've identified the field as a User field and that you want the full name):

    strUserName = getFieldValue(forBody, fieldName, false);

    beanDomainUser = serverBean.getUserBean(strUserName);

    stringBuilder.append(beanDomainUser.getFullName());

    You may need to change around some of the variable names, we have refactored our code to improve the readability of emailAdvanced.js, so i don't have the original version close at hand. You may also want to add error handling/ check if the username is valid before using it, etc.

    Hope that helps,

    Matt

    JensN.1-VisitorAuthor
    1-Visitor
    June 27, 2013

    Hi Matt,

    thanks for your answer. And because you asked for the different js-Files i've had a look at our server and found another mail-script, which expands a userfield into a more human readable format

    regards, Jens