9 Using Scripting for User Cache Queries

Job and case management triggers often need to convert user IDs to user names and extract user attributes such as emails. EDQ 12.2.1.4.4 provides a script library with functions for user cache and user query. This chapter describes how to use the script library.

To use the library, add this line to the top of the script:

addLibrary("usercache")

The library publishes an object named usercache in the script, which includes the following functions:

Name Description

user = usercache.getUser(id)

Map a numeric ID to a user object. Return null if no user is found. The user may be retrieved from the record of deleted users.

user = usercache.getLiveUser(id)

Map a numeric ID to an existing user. Users recorded as deleted are not returned.

user = usercache.lookup(username, [withid])

Lookup a user by username by searching all configured realms. If withid is omitted or is true, an internal ID is allocated for the user if this has not been done before. Internal IDs are required for certain APIs such as case assignment.

user = usercache.lookupInRealm(username, realm, [withid])

Lookup a user by username in a single realm. Use null for the internal realm.

The user object returned by these method has the following read-only properties:

Property Description

id

Internal ID of the user. The user with ID 0 is the special "system user".

userName

The user name.

displayName

User display name. Defaults to user identity. userdisplayname setting in login.properties overrides this value.

realm

The user realm. null for the "internal" realm.

identity

The internal user identity - username@realm.

fullName

The user's full name.

emailAddress

The user's email address.

organization

The user's organization string.

groups

Array of strings representing the user's group membership.