How to Get the Current User's Operator Information in Data Transforms
Introduction
When building Pega applications, you'll often need to access information about the current user (operator). This tutorial will show you two simple ways to get operator information inside Data Transforms and Activities.
Using pxRequestor
The simplest way to get basic operator information is by using the pxRequestor page.
What is pxRequestor? The pxRequestor page belongs to the Code-Pega-Requestor class and contains information related to the current user's session.
How to configure this in a Data Transform:
1. In the 'Pages and Classes' tab:
- Add pxRequestor in the Page Name field
- Add Code-Pega-Requestor in the Class field
2. In the 'Definition' tab:
- Set your target (for example, 'Param.CurrentOperatorId')
- Set the source to pxRequestor.pyUserIdentifier
Getting more information using D_pxOperatorDetails DataPage
While pxRequestor is useful, it doesn't contain all operator information. For more details like the operator's email address, you can use the D_pxOperatorDetails DataPage.
How to configure this:
1. In the 'Pages and Classes' tab:
- Add OperatorDetails in the Page Name field
- Add Data-Admin-Operator-ID in the Class field
2. In the 'Definition' tab:
- Set your target to OperatorDetails
- Set the source to D_pxOperatorDetails[OperatorId:Param.CurrentOperatorId]
3. To get specific information (like email):
- Set another target (for example, 'Param.CurrentOperatorEmail')
- Set the source to OperatorDetails.pyAddresses(Email).pyEmailAddress
Alternative Approach
You might also see implementations using a Page Name called OperatorID with the Class Data-Admin-Operator-ID. In most cases, this provides the same basic operator information, but your choice should depend on your specific requirements.
Choosing Between Code-Pega-Requestor and Data-Admin-Operator-ID
Key Differences
Code-Pega-Requestor:
- Related to the user's current session
- Contains information about the user's session
- Includes details like requester type and associated operator
- Used to access session-specific data and behaviors
Data-Admin-Operator-ID:
- Specifically designed for storing and managing operator information
- Contains personal details and access rights
- Stores information like encrypted passwords and access groups
- Used when you need detailed operator information
When to Use Each Option
Use Code-Pega-Requestor when:
- You need to access session-related information
- You want to work with the requester's current context
- You're dealing with temporary or session-specific data
- You need information about the current request environment
Use Data-Admin-Operator-ID when:
- You need detailed information about the operator
- You're working with the operator's identity, roles, and access rights
- You need to access operator properties not available in the session context
- You're performing operations that require persistent operator data