Skip to main content
1-Visitor
Jun 26, 2013 10:05 AM UTC
Solved

substitution-keywords for userdata in javamail.js?

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

    1-Visitor
    Jun 26, 2013 5:18 PM UTC

    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

    2 replies

    1-Visitor
    Jun 26, 2013 5:18 PM UTC

    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

    Translate
    JensN.1-VisitorAuthor
    1-Visitor
    Jun 27, 2013 1:47 PM UTC

    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

    Translate