Sending Email Notifications in a User's Preferred Language

This section provides an overview of sending email notifications in a user's preferred language.

If your organization has PeopleSoft users who speak multiple languages, you can send email notifications in a user’s preferred language. You have these options:

  • Sending email notifications using SetLanguage( ).

  • Storing preconfigured email text in the Message Catalog.

When developing custom notifications involving multiple languages, consider the following:

  • The PeopleSoft system does not translate email text from one language to another.

    This discussion assumes that you implement one of the methods described in this section to route emails to users in their preferred language.

  • When calling the SetLanguage ( ) online, only the language of the sender can be accessed.

    The page buffer contains only the language of the user currently accessing the component. If used in an Application Engine program (in batch mode), multiple languages can be accessed.

  • The Notification class does not support multiple languages for each recipient.

    The system sends the email in the language of the sender and not each individual recipient. The page buffer contains only the language of the user currently accessing the component.

  • If you do not implement any custom email notifications to deal with multiple languages, the system sends email notifications only in the language last used (the language of the sender).

The PeopleSoft system does not translate email content when sending email. However you can use predefined text in the message catalog or Notification templates to accommodate different languages. Using the SetLanguage( ) PeopleCode function enables the system to read the user profile language preference of the intended recipient and send an email in that user’s preferred language.

If there are multiple recipients with different language preferences, then individual emails can be sent to each recipient using a loop around the SetLanguage( ) and TriggerBusinessEvent ( ) function calls. The same method can be applied to SendMail.

As an example, assuming the TO field is a Role mapped to a field SEND_TO_ROLE without route control, you can make the following changes:

To send email notifications using SetLanguage( ):

  1. Change the field map for the TO field in Activity email routing to Roleuser by Oprid Qry or Roleuser by Roleuser Qry.

  2. Map the bind variable to a field on the page (the value of which will be formatted at runtime in PeopleCode).

    For this example, assume the field to be RECEIVER_ID. It can be a field of a derived/work record.

  3. In the event for which the TriggerBusinessEvent, or SendMail, is called, use the following code as a model, and modify the emphasized variables:

    Local Rowset &ROLE_USER;
    
    /* 1. Retrieve the TO user list */
    /* Create a rowset to retrieve all users for the role */
    &ROLE_USER = CreateRowset(Record.ROLEUSER_VW);
    &ROLE_USER.Fill("where ROLENAME= :1", SEND_TO_ROLE);
    
    /* Loop through user list to send email in their language code */
    For &i = 1 To &ROLE_USER.ActiveRowCountRECEIVER_ID = &ROLE_USER(&i).ROLEUSER_VW.OPRID.Value;
       
       /* 2. Get the user language code and set the language code*/
       SQLExec("Select LANGUAGE_CD FROM PSOPRDEFN where OPRID = :1", &OPRID, &LAN_CD);
       &temp = SetLanguage(&LAN_CD);
    /* check return code &temp for error .....*/
    
    /* 3. Retrieve text from message catalog for the language code */
    &subject = MsgGetText(msg_set, msg_num_subject, "");
    &text = MsgGetText(msg_set, msg_num_text, "");
    /*..... Format fields mapped in email route for translation .....*/
    /* RECORD.FIELD_SUBJECT.Value = &subject; */
    /* RECORD.FIELD_TEXT.Value = &text; */
    
       /* 4. Call TriggerBusinessEvent or SendMail to send email */
    &temp = TriggerBusinessEvent(BusProcess."bus_proc_name", 
    BusActivity."activity_name", BusEvent."event_name");
    /* &temp = SendMail(0, RECEIVER_ID, "", "", &subject, &text); */
       
    End-For;
    
    /* 5. Set language code back to current user */
    SQLExec("Select LANGUAGE_CD FROM PSOPRDEFN where OPRID = :1", %OperatorId, &ORIGINAL_LANGCD);
    &temp = SetLanguage(&ORIGINAL_LANGCD);
    /*..... Or &temp = SetLanguage(%Language).....*/
    %OperatorId, &ORIGINAL_LANGCD);
    &temp = SetLanguage(&ORIGINAL_LANGCD);
    /*..... Or &temp = SetLanguage(%Language).....*/
    

For generic email notifications, such as “An item has been added to your worklist,” you can store copies of the text of this email in the message catalog for as many languages as you support. During the notification, you include PeopleCode to use the appropriate text based on a user’s preferred language.

Note: This method can run online.