Hiding Virtual Agent Widget for HRBP Users via HR_Criteria().evaluateById in Agent Chat Config
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Requirement
I need to hide the Virtual Agent (VA) chat widget on the Employee Center for users who are HR Business Partners (HRBPs). The condition is based on the HR Profile field u_function = 'Human Resources'.
⚙️ Setup
HR Criteria: Checks Function is Human Resources on the HR Profile.
User Criteria: Uses a script to evaluate the HR Criteria: new sn_hr_core.HR_Criteria().evaluateById('SYS_ID_OF_HRBP_HR_CRITERIA', user_id)
The Challenge / Code Review
I am implementing this logic in the Server script of the Agent Chat Configuration record (sp_agent_chat_config) to hide the widget by setting configObj.live_agent_only = false.
Script in Agent Chat Configuration:
JavaScript
// Example using the logic to evaluate the User Criteria (which evaluates the HR Criteria)
var hrbpUserCriteriaSysId = 'SYS_ID_OF_HRBP_HR_CRITERIA';
var isHRBP = new sn_hr_core.HR_Criteria().evaluateById(hrbpUserCriteriaSysId, gs.getUserID());
if (isHRBP) {
configObj.live_agent_only = false;
}
return configObj;
// ... rest of the standard config object setup ...
Question:
Is using new sn_hr_core.HR_Criteria().evaluateById() directly inside the Agent Chat Configuration Server Script a reliable and supported method for determining user eligibility and controlling the chat widget display? Are there better alternatives for this specific task?
System Log Error (Possibly Unrelated)
While testing, we are consistently seeing the following error in the system logs whenever a chat session is initiated (regardless of the exclusion script outcome). We suspect this is a separate Virtual Agent/NLU configuration issue, but we are reporting it for complete context:
"Solution GlideRecord does not exist, please train the solution definition"
