Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

HRSD Activity

P1234
Tera Contributor

Im new to learn HRSD :

 

How to implement Knowledge author i want to hide all the Non-HR can & cannot read criteria from the HR knowledge bases HR All Employees & HR Agents so that this can prevent the incorrect criteria from the being selected.

 

Already implemented from my side but not working 

 

STEP 1: Add a Field to Identify HR-Specific Criteria

System Definition > Tables

Search for the table: User Criteria (sys_user_criteria)

Click Create new field:

Label: Is HR Criteria

Column name: is_hr_criteria: Save

 

STEP 2: Tag HR User Criteria

Go to User Criteria (sys_user_criteria)

Open each HR-related user criteria record.

Check the Is HR Criteria checkbox.

 

STEP 3: Restrict Can Read / Cannot Read Fields on Knowledge Articles

System Definition > Dictionary

Search for the field: canRead on table kb_knowledge

Set a Reference Qualifier with the following condition:


var kb = current.kb_knowledge_base;
if (kb == '<HR_ALL_EMPLOYEES_KB_SYS_ID>' || kb == '<HR_AGENTS_KB_SYS_ID>') {
'is_hr_criteria=true';
} else {
'';
}

Do the same for the cannotRead field.

Replace <HR_ALL_EMPLOYEES_KB_SYS_ID> and <HR_AGENTS_KB_SYS_ID> with the sys_ids of your HR knowledge bases (from the kb_knowledge_base table).

 


Step 4 : Add Client Script for Dynamic Filtering


Create a new Client Script:
Name : HR Case
Table : kb_knowledge
Type : onChange
Field : kb_knowledge_base

Script:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') return;

var hrKBs = ['<HR_ALL_EMPLOYEES_KB_SYS_ID>', '<HR_AGENTS_KB_SYS_ID>'];

if (hrKBs.includes(newValue)) {
g_form.setReferenceQual('canRead', 'is_hr_criteria=true');
g_form.setReferenceQual('cannotRead', 'is_hr_criteria=true');
} else {
g_form.setReferenceQual('canRead', '');
g_form.setReferenceQual('cannotRead', '');
  }
}

0 REPLIES 0