---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# SkillDeterminationUtils - Scoped

# SkillDeterminationUtils - Scoped {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read

The SkillDeterminationUtils script include provides utility methods to get or set work item skill data.

This script include requires the Skill Determination (com.snc.skill_determination) plugin and is provided within the `sn_skill_rule` namespace.

## SkillDeterminationUtils - SkillDeterminationUtils() {#ariaid-title2}

Constructor to create an instance of SkillDeterminationUtils.
{#SkillDeterminationUtilsConstructor__table_v2y_sh5_fhb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 1. Parameters]

{#SkillDeterminationUtilsConstructor__table_v2y_sh5_fhb}  

    var util = new sn_skill_rule.SkillDeterminationUtils();

## SkillDeterminationUtils - assignSkillsToWorkItem(Array skills, GlideRecord now_GR) {#ariaid-title3}

Assigns an array of active skill objects to a work item.
{#assignSkillsToWorkItem_A_GR__table_cv2_w45_fhb__entry__3}

| Name | Type | Description |
|-|-|-|
| skills | Array | Array of active skill objects to be assigned. |
| skill.skillName | String | Name of the skill. |
| skill.skillSysId | String | Sys ID of the skill. |
| skill.mandatory | Boolean | True if the skill is mandatory, false otherwise. |
| skill.skillLevelName | String | Optional skill level name. |
| skill.skillLevelSysId | String | Optional skill level Sys ID. |
| now_GR | GlideRecord | GlideRecord of the work item on which to assign skills. |
[Table 2. Parameters]

{#assignSkillsToWorkItem_A_GR__table_cv2_w45_fhb} {#assignSkillsToWorkItem_A_GR__table_dv2_w45_fhb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 3. Returns]

{#assignSkillsToWorkItem_A_GR__table_dv2_w45_fhb}  
The examples below create an Interaction record using the table name (interaction) and show
how to assign skills to the interaction work item, creating a record in the Interaction
Skills \[interaction_m2m_skill\] table.

Use case 1: Use returned results from determineWorkItemSkills() to assign skills to a work
item from the Interaction table.

    // Create an interaction record
    var now_GR = new GlideRecord('interaction');
    now_GR.insert();

    var util = new sn_skill_rule.SkillDeterminationUtils();

    // Get interaction skills interaction 
    // and specify if any are mandatory
    var result = util.determineWorkItemSkills(now_GR);

    // Assign skills determined by result and 
    // assign them to the interaction work item
    util.assignSkillsToWorkItem(result, now_GR);

Use case 2: Manually insert skills array. In this case, assign IT skills to the Interaction
work item.

    var now_GR = new GlideRecord('interaction');
    now_GR.insert();

    var util = new sn_skill_rule.SkillDeterminationUtils();

    var skills = [{"skillSysId":"2eb1c2029f100200a3bc1471367fcfe4", "skillName":"IT", "mandatory":true, "skillLevelName":"", "skillLevelSysId":null}];

    util.assignSkillsToWorkItem(skills, now_GR);

## SkillDeterminationUtils - determineWorkItemSkills(GlideRecord now_GR) {#ariaid-title4}

Gets skills for a specified work item, indicates if the skills are mandatory, and lists
any skill levels.
{#determineWorkItemSkills_GR__table_hct_yl5_fhb__entry__3}

| Name | Type | Description |
|-|-|-|
| now_GR | GlideRecord | GlideRecord of a work item from any interaction or task table extension. |
[Table 4. Parameters]

{#determineWorkItemSkills_GR__table_hct_yl5_fhb} {#determineWorkItemSkills_GR__table_ict_yl5_fhb__entry__2}

| Type | Description |
|-|-|
| Array | One or more skill objects. * skillSysId: String. Sys ID of the skill from the Skills \[cmn_skill\] table. * skillName: String. Name of the skill. * mandatory: Boolean. True if mandatory, false otherwise. * skillLevelName: If skill exists, name of the skill level. * skillLevelSysId: If skill exists, Sys ID of the skill level from the Skill Levels \[cmn_skill_level\] table. {#determineWorkItemSkills_GR__ul_bwb_5nb_j3b} |
[Table 5. Returns]

{#determineWorkItemSkills_GR__table_ict_yl5_fhb}  
The following script creates an interaction record, gets skills for the interaction work
item, and indicates if the skills are mandatory.

    // Create an interaction record
    var now_GR = new GlideRecord('interaction');
    now_GR.insert();

    var util = new sn_skill_rule.SkillDeterminationUtils();

    var result = util.determineWorkItemSkills(now_GR);
    gs.info(JSON.stringify(result));

Output:

    [{"skillSysId":"6c0f025c7f672300a8b1bdc8adfa917f",
    "skillName":"Premier Support Certified",
    "mandatory":false,"skillLevelName":"",
    "skillLevelSysId":null}]


