SkillDeterminationUtils - Scoped

  • リリースバージョン: Australia
  • 更新日 2026年03月12日
  • 所要時間:6分
  • 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()

    Constructor to create an instance of SkillDeterminationUtils.

    表 : 1. Parameters
    Name Type Description
    None
    var util = new sn_skill_rule.SkillDeterminationUtils();

    SkillDeterminationUtils - assignSkillsToWorkItem(Array skills, GlideRecord now_GR)

    Assigns an array of active skill objects to a work item.

    表 : 2. Parameters
    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.
    表 : 3. Returns
    Type Description
    None

    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)

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

    表 : 4. Parameters
    Name Type Description
    now_GR GlideRecord GlideRecord of a work item from any interaction or task table extension.
    表 : 5. Returns
    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.

    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}]