Functions and Groovy Expressions

This topic describes various functions and Groovy expressions that you can use when configuring alerts using the Alerts Composer.

The return attributes for the person can be one of these:

  • PersonId

  • WorkEmail

  • DisplayName

  • FirstName

  • LastName

  • UserName

Functions

This table describes the functions that are supported for alerts. A maximum of 25 results are retrieved. If the results exceed 25, warning messages will be displayed in the log.

Function

Description

Usage

Example

  • Name: hrRepList

  • Display name: Human resources representative

Returns HR Representative person attributes for the PersonId.

Recipient Section

Email is : ${AlertUtils.toString(AlertUtils.hrRepList(workers.PersonId).WorkEmail)}

User name : ${AlertUtils.toString(AlertUtils.hrRepList(workers.PersonId).UserName)}

Body or Subject Section

First Name is: ${AlertUtils.hrRepList(workers.PersonId).FirstName)}

First Name is: ${AlertUtils.toString(AlertUtils.hrRepList(workers.PersonId).FirstName)}

Loop Example

First Name is: ${AlertUtils.loop('workers','${AlertUtils.toString(AlertUtils.hrRepList(workers.PersonId).FirstName)}')}

Recipient Section

Email is: Christopher.Brown@example.com,William.Jones@example.com

User Name is: Christopher.Brown,William.Jones

Body or Subject Section

First Name is: [Christopher,William]

First Name is: Christopher,William

Loop Example

First Name is: Christopher,William

  • Name: payRepList

  • Display name: Payroll representative

Returns Payroll Representative person attributes for the PersonId.

Recipient Section

Email is : ${AlertUtils.toString(AlertUtils.payRepList(workers.PersonId).WorkEmail)}

User name : ${AlertUtils.toString(AlertUtils.payRepList(workers.PersonId).UserName)}

Body or Subject Section

First Name is: ${AlertUtils.toString(AlertUtils.payRepList(workers.PersonId).FirstName)}

Loop Example

First Name is: ${AlertUtils.loop('workers','${AlertUtils.toString(AlertUtils.payRepList(workers.PersonId).FirstName)}')}

Recipient Section

Email is: Christopher.Brown@example.com,William.Jones@example.com

User Name is: Christopher.Brown,William.Jones

Body or Subject Section

First Name is: Christopher,William

Loop Example

First Name is: Christopher,William

  • Name: benRepList

  • Display name: Benefits representative

Returns Benefits Representative person attributes for the PersonId.

Recipient Section

Email is : ${AlertUtils.toString(AlertUtils.benRepList(workers.PersonId).WorkEmail)}

User name : ${AlertUtils.toString(AlertUtils.benRepList(workers.PersonId).UserName)}

Body or Subject Section

First Name is: ${AlertUtils.toString(AlertUtils.benRepList(workers.PersonId).FirstName)}

Loop Example

First Name is: ${AlertUtils.loop('workers','${AlertUtils.toString(AlertUtils.benRepList(workers.PersonId).FirstName)}')}

Recipient Section

Email is: Christopher.Brown@example.com,William.Jones@example.com

User Name is: Christopher.Brown,William.Jones

Body or Subject Section

First Name is: Christopher,William

Loop Example

First Name is: Christopher,William

  • Name: unionRepList

  • Display name: Union representative

Returns Union Representative person attributes for the PersonId.

Recipient Section

Email is : ${AlertUtils.toString(AlertUtils.unionRepList(workers.PersonId).WorkEmail)}

User name : ${AlertUtils.toString(AlertUtils.unionRepList(workers.PersonId).UserName)}

Body or Subject Section

First Name is: ${AlertUtils.toString(AlertUtils.unionRepList(workers.PersonId).FirstName)}

Loop Example

First Name is: ${AlertUtils.loop('workers','${AlertUtils.toString(AlertUtils.unionRepList(workers.PersonId).FirstName)}')}

Recipient Section

Email is: Christopher.Brown@example.com,William.Jones@example.com

User Name is: Christopher.Brown,William.Jones

Body or Subject Section

First Name is: Christopher,William

Loop Example

First Name is: Christopher,William

  • Name: empManagerList

  • Display name: Employee manager

Returns employee's manager person attributes for the PersonId.

Recipient Section

Email is : ${AlertUtils.toString(AlertUtils.empManagersList(workers.PersonId).WorkEmail)}

User name : ${AlertUtils.toString(AlertUtils.empManagersList(workers.PersonId).UserName)}

Body or Subject Section

First Name is: ${AlertUtils.toString(AlertUtils.empManagersList(workers.PersonId).FirstName)}

Recipient Section

Email is: Diane.Brown@example.com

User Name is: Diane.Brown

Body or Subject Section

First Name is: Diane

  • Name: roleMemberList

  • Display name: Role members by role

Returns all the active users who are assigned to a particular role for the role code provided.

Recipient Section

Returns the users with person details who have been assigned the provided Role_Name or Role_Code

Email is: ${AlertUtils.toString(AlertUtils.roleMemberList("CUSTOM_X_JOB_ROLE_CODE").WorkEmail)}

User name is: ${AlertUtils.toString(AlertUtils.roleMemberList("CUSTOM_X_JOB_ROLE_CODE").UserName)}

Body or Subject Section

First Name is: ${AlertUtils.toString(AlertUtils.roleMemberList("CUSTOM_X_JOB_ROLE_CODE").FirstName)}

Recipient Section

Email is: Christopher.Brown@example.com,William.Jones@example.com

User Name is: Christopher.Brown,William.Jones

Body or Subject Section

First Name is: Christopher,William

  • Name: toString

  • Display Name: None

Converts an array of objects into comma separated strings.

${workRelationships.assignments.AssignmentName}

${AlertUtils.toString(workRelationships.assignments.AssignmentName)}

[Assignment A, Assignment B]

Assignment A, Assignment B

  • Name: person

  • Display name: Person details

Returns person attributes for the PersonId.

Person Name is ${AlertUtils.person(workers.PersonId).DisplayName}

Person Name is Edward

  • Name: getSysdate

  • Display name: System date

Returns the system date.

${AlertUtils.getSysdate()}

2016-04-25

  • Name: getSystimestamp

  • Display name: System time stamp

Returns the system date and time.

${AlertUtils.getSystimestamp()}

2016-04-25 23:44:52.0

  • Name: formatNumber

  • Display name: Format number

Formats the number to the specified Java number format. Supported formats are available at https://docs.oracle.com/javase/7/docs/api/java/text/NumberFormat.html.

Probation Period is ${AlertUtils.formatNumber(workers.workRelationships.assignments[0].ProbationPeriod, '9,999,999')} days

Probation Period is 240 days

  • Name: formatDate

  • Display name: Format date

Formats the date to the specified Java date format. Supported formats are available at https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

Note: Date provided must be in the [yyyy-MM-dd] format, which is the default date format for Application Developer Framework (ADF) REST response.

Date is : ${AlertUtils.formatDate(workers.workRelationships.assignments.ProbationEndDate, 'dd-MMM-yyyy')}

Date is : [30-Mar-2022]

Name: getLookupMeaning

Returns the Lookup meaning based on the user's preference language.

Lookup meaning ${AlertUtils.getLookupMeaning(<LookupType>,<LookupCode>)}

${AlertUtils.getLookupMeaning('YES_NO','Y')}

Yes

Name: getLookupMeaning

Returns the Lookup meaning based on the user's preference language for the legislation stripe

${AlertUtils.getLookupMeaning(<LookupType>,<LookupCode>, <LegislationCode>)}

${AlertUtils.getLookupMeaning('GENDER','M','US')}

Male

  • Name: loop

  • Display name: Loop

Loops through a collection. This function can be used to construct tables in the message content as follows:

${AlertUtils.loop('ResourceName1,ResourceName2' , 'Content1','Content2')}

The resource names are separated by commas and the contents that follow are used to append data in the given order. For each Resource Name1 record, the respective content for Resource Name2 is appended. This happens in a nested manner.

Rules

  • The list of resource names must be in hierarchical order. Every child resource must be preceded with the parent resource (unless it is a root-level child resource).

    For example, consider a hierarchy with root as workers, child as workRelationships, and grandchild as assignments. To create a loop on assignments, you must also include the workRelationships resource in the API.

    ${AlertUtils.loop('workRelationships,assignments','<tr><td>${AssignmentNumber}</td>','<td>${Name}</td></tr>')}

  • An attribute at each level can be referenced directly. A parent attribute can be accessed in the child content using the expression ${parentResourceName.AttributeName}.

    For example, ${workers.PersonId}

Sample 1

Hello ${FirstName},

Visas of these employees expire in the next 30 days:

<table>

${AlertFct.loop('visas','<tr><td>${IssuingCountry}</td><td>${VisaPermitNumber}</td></tr>')}

</table>

Thank you.

Sample 2

Hello ${FirstName},

Visas of these employees expire in the next 30 days:

<table>

${AlertUtils.loop('workers,visasPermits','<tr><td>${workers.DisplayName}</td>','<td>${IssuingCountry} </td><td>${ExpirationDate}</td></tr>')}

</table>

Thank you.

Sample 1

Hello John,

Visas of these employees expire in the next 30 days:


US		NBC-88457
US		234234

Thank you.

Sample 2

Hello John,

Visas of these employees expire in the next 30 days:

Name		Issuing Country		Expiration Date
Employee1		US		2016-03-14
Employee1		IN		2016-03-20
Employee2		US		2016-02-18
Employee3		US		2015-05-01
Employee4		US		2015-12-14
Employee5		US		2015-05-17
Employee5		UK		2015-09-17

Thank you.

Groovy Expressions

Alerts Composer supports Groovy expressions to substitute variables and add conditions based on the values provided at runtime. The following table shows some examples.

Groovy Expression

Example

Hi ${AlertUtils.toString(workers.names.LastName)}

Your visa issued in ${AlertUtils.toString(visasPermits.IssuingCountry)} expires on ${AlertUtils.toString(visasPermits.ExpirationDate)}.

Hi John

Your visa issued in GB, US expires on 2022-03-10, 2022-01-11.

Hi ${AlertUtils.toString(workers.names.LastName)}

<%

asgStr ="";

for(visaPermit in visasPermits)

{

asgStr = asgStr + visaPermit.IssuingCountry+" ";

}

print("Multiple visas are issued for employee: "+asgStr);

%>

Regards,

Administrator

Hi John

Multiple visas are issued for employee: GB

Regards,

Administrator