This guide provides information on modifying greetings and names within Alma Letters, including working with preferred names.
Supplemental information can be found in Ex Libris Documentation: Configuring Alma Letters.
One of the following Alma User Roles is required to perform the tasks outlined on this page:
It is useful to understand where Letter Components/Templates are used in Alma Letters.
There are 4 Letter Components/Templates used to construct the body of Alma Letters. They are listed below and displayed in the sample letter image to the right.
Alma Letters utilize names and greetings in 3 potential places.
Not all Alma Letters utilize templates in the same way. As of 12/12/2024, this is the current state of greetings and names in Alma Letters:
For a full table that shows which letters are using templates, which are not, and which have their own unique greeting fields visit our Alma Letters Using Templates for Greetings and Names page.
The senderReceiver.xsl Component is found under Configuration -> General -> Letters -> Components Configuration -> senderReceiver.xsl
The component calls a user's name in two potential locations, depending whether the notification_data/user_for_printing field is being used or the notification_data/receivers/receiver/user field.
Note that the code for user_for_printing is calling a single XML element that contains the user's last name and first name separated by a comma, while the code for /receivers/receiver/user is calling two XML elements, the last name element and first name element, which are separated by a space written in HTML code ( ).
To reiterate, there are two places where this template is generating LastName+FirstName depending on the situation, the method for creating LastName+FirstName is different in each place, and the output looks slightly different in each place. And, again, neither of these take Preferred Names into account.
"notification_data/user_for_printing/name" = "LastName, FirstName"
"/receivers/receiver/user/last_name" "/receivers/receiver/user/first_name" = "LastName FirstName"
For the user_for_printing section, CARLI is utilizing the following code to check for preferred names and fall back on default names when no preferred name is found. This code allows for preferred first and/or last names in any combination.
Note 1: This code utilizes two XML elements, preferred_last_name and preferred_first_name, because a single field with "PreferredLastName, PreferredFirstName" does not exist.
Note 2: CARLI decided to reverse the name order, changing from "LastName, FirstName" to "FirstName LastName" in this section.
Replace the following line of code (line 18 in the above screenshot):
<tr><td><b><xsl:value-of select="notification_data/user_for_printing/name"/></b></td></tr>
With the following:
<tr><td><b>
<xsl:choose>
<xsl:when test="(notification_data/user_for_printing/preferred_first_name!='')">
<xsl:value-of select="notification_data/user_for_printing/preferred_first_name" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="notification_data/user_for_printing/first_name" />
</xsl:otherwise>
</xsl:choose> 
<xsl:choose>
<xsl:when test="(notification_data/user_for_printing/preferred_last_name!='')">
<xsl:value-of select="notification_data/user_for_printing/preferred_last_name" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="notification_data/user_for_printing/last_name" />
</xsl:otherwise>
</xsl:choose>
</b></td></tr>
The code above can be written as a single line if you prefer:
<tr><td><b><xsl:choose><xsl:when test="(notification_data/user_for_printing/preferred_first_name!='')"><xsl:value-of select="notification_data/user_for_printing/preferred_first_name" /></xsl:when><xsl:otherwise><xsl:value-of select="notification_data/user_for_printing/first_name" /></xsl:otherwise></xsl:choose> <xsl:choose><xsl:when test="(notification_data/user_for_printing/preferred_last_name!='')"><xsl:value-of select="notification_data/user_for_printing/preferred_last_name" /></xsl:when><xsl:otherwise><xsl:value-of select="notification_data/user_for_printing/last_name" /></xsl:otherwise></xsl:choose></b></td></tr>
RESULT
Given the following user metadata:
<first_name>Jonathan</first_name>
<last_name>Doe</last_name>
<preferred_first_name>Jon</preferred_first_name>
<preferred_last_name>Doe-Smith</preferred_last_name>
The above code will produce the following:
Jon Doe-Smith
For the receivers/receiver/user section of the template, a similar block of code is used to check for preferred names and fall back on default names when no preferred name is found.
This code calls the XML fields slightly differently from above because the line <xsl:for-each select="notification_data/receivers/receiver/user"> places us in the notification_data/receivers/receiver/user section of the XML already.
Note: CARLI decided to reverse the name order, changing from "LastName FirstName" to "FirstName LastName" in this section.
Replace the following line of code (line 39 in the above screenshot):
<tr><td><b><xsl:value-of select="last_name"/> <xsl:value-of select="first_name"/></b></td></tr>
With the following:
<tr><td><b>
<xsl:choose>
<xsl:when test="(preferred_first_name!='')">
<xsl:value-of select="preferred_first_name" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="first_name" />
</xsl:otherwise></xsl:choose> 
<xsl:choose>
<xsl:when test="(preferred_last_name!='')">
<xsl:value-of select="preferred_last_name" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="last_name" />
</xsl:otherwise>
</xsl:choose>
</b></td></tr>
The code above can be written as a single line if you prefer:
<tr><td><b><xsl:choose><xsl:when test="(preferred_first_name!='')"><xsl:value-of select="preferred_first_name" /></xsl:when><xsl:otherwise><xsl:value-of select="first_name" /></xsl:otherwise></xsl:choose> <xsl:choose><xsl:when test="(preferred_last_name!='')"><xsl:value-of select="preferred_last_name" /></xsl:when><xsl:otherwise><xsl:value-of select="last_name" /></xsl:otherwise></xsl:choose></b></td></tr>
RESULT
Given the following user metadata:
<first_name>Jonathan</first_name>
<last_name>Doe</last_name>
<preferred_first_name>Jon</preferred_first_name>
<preferred_last_name>Doe-Smith</preferred_last_name>
The above code will produce the following:
Jon Doe-Smith
The mailReason.xsl Component is found under Configuration -> General -> Letters -> Components Configuration -> mailReason.xsl
By default, the mailReason.xsl Component/Template displays the greeting "Dear Sir/Madam {lastName}" in any letter using that template. This can be found in the screenshots below.
At CARLI, we have replaced the Dear Sir/Madam Label with "Hello," and removed the XSL code for last name altogether. This results in a simplified greeting that does not utilize any names.
The XSL code for this template now looks like the following:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="toWhomIsConcerned">
<table cellspacing="0" cellpadding="5" border="0">
<tr>
<td>
<xsl:for-each select="notification_data">
<h3>@@dear@@</h3>
</xsl:for-each>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
23 letters have their own @@header@@ or @@dear@@ greeting in their XSL. Editing the mailReason.xsl template will not change the greetings in these letters.
These letters must be edited individually by changing the text in the label for the greeting.
Letters using their own @@header@@ or @@dear@@ field for greeting instead of mailReason.xsl | |
---|---|
Borrower Claim Email Letter | Lender Checked-in Email Letter |
Borrower Receive Email Letter | Lender Reject Email Letter |
Borrower Return Email Letter | Lender Renew Response Email Letter |
Change Rapido Request Terms Letter | Lender Ship Email Letter |
Externally Obtained Email Letter | Lender Will Supply Email Letter |
Ful Cancel Email Letter | Lending Recall Email Letter |
Ful Damaged Email Letter | Query To Patron Letter |
Ful Lost Email Letter | Rapido member letter |
Ful Outgoing Email Letter | Resend Notification Letter |
Ful Renew Email Letter | Resource Sharing Request Confirmation Letter |
Ful Requests Report Letter | User Notifications Letter |
General Message Email Letter |
6 Alma Letters have a field in Labels for the greeting, but that field is not utilized. Changing this field in the labels area for these letters will do nothing.
5 of these letters do not call the mailReason.xsl template for greeting either, meaning they have no greeting at all.
1 letter, General Assign To Letter, does use the mailReason.xsl template.
The Ful Hold Shelf Request Slip Letter utilizes patron names in the Requested For portion of that letter. Below is the code we are using to incorporate Preferred Names in that section.
Note: CARLI has added middle initial to this section at the request of our libraries. If a user does not wish to have their middle initial appear, they can set their Preferred Middle Name to a space, which will result in the space being displayed instead of their default middle initial.
<b>@@requested_for@@</b>:
<xsl:choose>
<xsl:when test="(/notification_data/user_for_printing/preferred_last_name!='')">
<xsl:value-of select="/notification_data/user_for_printing/preferred_last_name" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="/notification_data/user_for_printing/last_name" />
</xsl:otherwise>
</xsl:choose>,
<xsl:choose>
<xsl:when test="(/notification_data/user_for_printing/preferred_first_name!='')">
<xsl:value-of select="/notification_data/user_for_printing/preferred_first_name" /> 
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="/notification_data/user_for_printing/first_name" /> 
</xsl:otherwise>
</xsl:choose> <xsl:choose>
<xsl:when test="(/notification_data/user_for_printing/preferred_middle_name!='')">
<xsl:value-of select="substring (/notification_data/user_for_printing/preferred_middle_name, 1,1)" />
</xsl:when>
<xsl:when test="(/notification_data/user_for_printing/middle_name!='')">
<xsl:value-of select="substring (/notification_data/user_for_printing/middle_name, 1,1)" />
</xsl:when>
</xsl:choose>
RESULT
Given the following user metadata:
<first_name>Jonathan</first_name>
<last_name>Doe</last_name>
<middle_name>Jacob</middle_name>
<preferred_first_name>Jon</preferred_first_name>
<preferred_last_name>Doe-Smith</preferred_last_name>
<preferred_middle_name>Samuel</preferred_middle_name>
The above code will produce the following:
Doe-Smith, Jon S
For scenarios where it is necessary to utilize a patron's name, such as the senderReceiver.xsl Component/Template, it is ideal to use code that checks for preferred name, but can fall back to the default name if a preferred name is not found.
Below is one example of XSL code that checks for preferred first name, prints that name if found, and prints the default name if no preferred name is found. The code then repeats the process for preferred last name. This is the code we are currently using in our senderReceiver.xsl Component/Template.
<xsl:choose>
<xsl:when test="(notification_data/user_for_printing/preferred_first_name!='')">
<xsl:value-of select="notification_data/user_for_printing/preferred_first_name" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="notification_data/user_for_printing/first_name" />
</xsl:otherwise>
</xsl:choose> 
<xsl:choose>
<xsl:when test="(notification_data/user_for_printing/preferred_last_name!='')">
<xsl:value-of select="notification_data/user_for_printing/preferred_last_name" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="notification_data/user_for_printing/last_name" />
</xsl:otherwise>
</xsl:choose>
RESULT
Given the following user metadata:
<first_name>Jonathan</first_name>
<last_name>Doe</last_name>
<preferred_first_name>Jon</preferred_first_name>
<preferred_last_name>Doe-Smith</preferred_last_name>
The above code will produce the following:
Jon Doe-Smith