Question
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Tata Consultancy Services
IN
Last activity: 14 Jun 2021 7:38 EDT
May I Know in which category i can find PresenceServiceAPI
I have requirement to Track the online presence of operators. I followed one article in PDN. There it is mentioned to use the PresenceService() API to configure these attributes. But i was not able to find the Presence Service API. May i know in which category i can see this API. I am using Pega 8.1 version.
Could anyone help me on this?
***Edited by Moderator Marissa to update Platform Capability tags****
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Northbridge
CA
Hi Sridhar,
PresenceService seems to be an engine API, so you may not find it in a category. But it's been referred in this Activity rule 'pzSetRequestorStateAsDisconnected' as
tools.getPresenceService()
-Shruthi
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Tata Consultancy Services
IN
Hi Shruthi,
My requirement is track the active users who logged into application. I followed the below PDN link to implement
https://community.pega.com/knowledgebase/articles/user-interface/tracking-online-presence-operators
Add the custom category to the Operator Presence channel.
- Click Designer Studio > User Interface > Notification channels.
- Click the Gear icon next to the Operator Presence channel.
- Click Add category, and enter the category name.(By default it is standard)
- Click Submit.
Configure your application component to subscribe to the channel.
- Added the dynamic layout
- Select the layout, and click the Gear icon to open the layout properties panel.
- Click Actions.
- Click Create an action set.
- Click Add an event, and select On load under Other events.
- Under Subscribe, select Operator Presence from the Channel name list.
- Select a category.
- Select the source of the operators list
I selected Data Page as source and provided OOTB Datapage "D_OperatorsList".
Hi Shruthi,
My requirement is track the active users who logged into application. I followed the below PDN link to implement
https://community.pega.com/knowledgebase/articles/user-interface/tracking-online-presence-operators
Add the custom category to the Operator Presence channel.
- Click Designer Studio > User Interface > Notification channels.
- Click the Gear icon next to the Operator Presence channel.
- Click Add category, and enter the category name.(By default it is standard)
- Click Submit.
Configure your application component to subscribe to the channel.
- Added the dynamic layout
- Select the layout, and click the Gear icon to open the layout properties panel.
- Click Actions.
- Click Create an action set.
- Click Add an event, and select On load under Other events.
- Under Subscribe, select Operator Presence from the Channel name list.
- Select a category.
- Select the source of the operators list
I selected Data Page as source and provided OOTB Datapage "D_OperatorsList".
Click Add an action for callback to select the operation to be performed after receiving the updates. I selected the refresh section and i called one activity which calling the custom java code
Custom Java code:
/* Below params are kept in param page and then fetch activity should be invoked */
oLog.info("Start");
List <String> operatorsList = (List <String>) tools.getParameterPage().getParameterValue("OperatorList");
oLog.info("OperatorList" +operatorsList);
List <PresenceQueryClause> clauses = new ArrayList <PresenceQueryClause> ();
String query = "A";
if (operatorsList != null) {
oLog.info("Entered if Condition");
PresenceQueryClause clause1= PresenceQueryClause.Builder.createEqualsClause('A', PresenceQueryClause.STANDARD_CATEGORY, PresenceStandardAttributes.STATE.getName(), "ACTIVE", false);
clauses.add(clause1);
oLog.info("Clause1" +clause1);
}
try {
List <PresenceRecord> results = tools.getPresenceService().queryPresence(query, clauses, PresenceQueryClause.STANDARD_CATEGORY);
oLog.info("Results" +results);
Map <String, PresenceRecord> fetchUsersResponseMap = new java.util.HashMap <String, PresenceRecord> ();
for (PresenceRecord record: results) {
fetchUsersResponseMap.put(record.getOperatorId(), record);
}
/* OperatorsPresenceMap params will be avaliable in param page */
tools.putParamValue("OperatorsPresenceMap", fetchUsersResponseMap);
} catch (PresenceException e) {
oLog.warnForced("QueryOnlinePresence: Exception occured", e);
}
But when i am running the above activity manually which is having the javacode. i am getting runtime exception. attaching the screen shots .
Could you please tell me if i am following correct or anything else i am missing.
Thanks for help in advance
Updated: 14 Jun 2021 7:38 EDT
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Pegasystems Inc.
IN
Seems like it is getPresenceService. You can find it's usage in OOTB activity pyFetchUsersPresenceByState.
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Tata Consultancy Services
IN
Hi Kanap2,
My requirement is track the active users who logged into application. I followed the below PDN link to implement
https://community.pega.com/knowledgebase/articles/user-interface/tracking-online-presence-operators
Add the custom category to the Operator Presence channel.
- Click Designer Studio > User Interface > Notification channels.
- Click the Gear icon next to the Operator Presence channel.
- Click Add category, and enter the category name.(By default it is standard)
- Click Submit.
Configure your application component to subscribe to the channel.
- Added the dynamic layout
- Select the layout, and click the Gear icon to open the layout properties panel.
- Click Actions.
- Click Create an action set.
- Click Add an event, and select On load under Other events.
- Under Subscribe, select Operator Presence from the Channel name list.
- Select a category.
- Select the source of the operators list
I selected Data Page as source and provided OOTB Datapage "D_OperatorsList".
Hi Kanap2,
My requirement is track the active users who logged into application. I followed the below PDN link to implement
https://community.pega.com/knowledgebase/articles/user-interface/tracking-online-presence-operators
Add the custom category to the Operator Presence channel.
- Click Designer Studio > User Interface > Notification channels.
- Click the Gear icon next to the Operator Presence channel.
- Click Add category, and enter the category name.(By default it is standard)
- Click Submit.
Configure your application component to subscribe to the channel.
- Added the dynamic layout
- Select the layout, and click the Gear icon to open the layout properties panel.
- Click Actions.
- Click Create an action set.
- Click Add an event, and select On load under Other events.
- Under Subscribe, select Operator Presence from the Channel name list.
- Select a category.
- Select the source of the operators list
I selected Data Page as source and provided OOTB Datapage "D_OperatorsList".
Click Add an action for callback to select the operation to be performed after receiving the updates. I selected the refresh section and i called one activity which calling the custom java code
Custom Java code:
/* Below params are kept in param page and then fetch activity should be invoked */
oLog.info("Start");
List <String> operatorsList = (List <String>) tools.getParameterPage().getParameterValue("OperatorList");
oLog.info("OperatorList" +operatorsList);
List <PresenceQueryClause> clauses = new ArrayList <PresenceQueryClause> ();
String query = "A";
if (operatorsList != null) {
oLog.info("Entered if Condition");
PresenceQueryClause clause1= PresenceQueryClause.Builder.createEqualsClause('A', PresenceQueryClause.STANDARD_CATEGORY, PresenceStandardAttributes.STATE.getName(), "ACTIVE", false);
clauses.add(clause1);
oLog.info("Clause1" +clause1);
}
try {
List <PresenceRecord> results = tools.getPresenceService().queryPresence(query, clauses, PresenceQueryClause.STANDARD_CATEGORY);
oLog.info("Results" +results);
Map <String, PresenceRecord> fetchUsersResponseMap = new java.util.HashMap <String, PresenceRecord> ();
for (PresenceRecord record: results) {
fetchUsersResponseMap.put(record.getOperatorId(), record);
}
/* OperatorsPresenceMap params will be avaliable in param page */
tools.putParamValue("OperatorsPresenceMap", fetchUsersResponseMap);
} catch (PresenceException e) {
oLog.warnForced("QueryOnlinePresence: Exception occured", e);
}
But when i am running the above activity manually which is having the javacode. i am getting runtime exception. attaching the screen shots .
Could you please tell me if i am following correct or anything else i am missing.
Thanks for help in advance
File Attachments
Updated: 14 Jun 2021 7:38 EDT
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Pegasystems Inc.
IN
There is one more approach to get the list of online operators.
D_pzRequestors data page returns lists of all requestors, we can filter by pyRequestorType=="Browser" to get the list of currently logged in operators.