cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

substitution-keywords for userdata in javamail.js?

JensN.
14-Alexandrite

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

ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

2 REPLIES 2

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.
14-Alexandrite
(To:matt_giltaji)

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

Announcements


Top Tags