logo

NJP

Including Resource Assignments within Project Templates

New article articles in ServiceNow Community · Apr 24, 2025 · article

DISCLAIMER: This article describes a proposed solution to support this use case.

The proposed solution requires configuration, as such, there is no liability for ServiceNow to provide support, apply changes, fix defects and review impact during future upgrades.

What problem does this solve?:

Being able to provide consistent Resource Assignments within Project Templates allows organizations to efficiently provide starting points for Projects that require the same role, group, or skill at certain points of a project plan or for specific types of projects.

This guide will walk you through configuring the platform to allow adding Resource Assignments to your Project Templates.

  • Configure Project Template elements for Resource Assignments
    This allows for Project Templates to capture Resource Assignments when saving as a Template
    1. Go to Project Administration > Settings > Template Config
    2. Add two (2) new configurations
      1. For Project
        * Table: Resource assignment [sn_plng_att_core_resource_assignment]
        * Parent Table: Project [pm_project]
        * Link element: Task
        * Active = true
        * Elements: assignment_type, effort_type, effort, group_resource, role, skill
        It is strongly recommended to minimize any additional elements, as we need to ensure creation of the Resource Assignments populate and work appropriately.
        * The name column (element) could be added if that is applicable and appropriate for your organization.
        * ***Test any additional elements THOROUGHLY!*
        JoshSutton_0-1745418439416.png
      2. For Project task
        * Table: Resource assignment [sn_plng_att_core_resource_assignment]
        * Parent Table: Project Task [pm_project_task]
        * Link element: Task
        * Active = true
        * Elements: assignment_type, effort_type, effort, group_resource, role, skill
        It is strongly recommended to minimize any additional elements, as we need to ensure creation of the Resource Assignments populate and work appropriately.
        * The name column (element) could be added if that is applicable and appropriate for your organization.
        * ***Test any additional elements THOROUGHLY!*
        JoshSutton_1-1745418929858.png
  • Create an Extension Point Script Include

    This allows for the business rules to fire for updating the Resource Assignments once applied via the Template

    1. Navigate to System Extension Points > Scripted Extension Points
      • Open ‘global.ProjectTemplate’
    2. Once on the record, click ‘Create implementation’ Related Link

      • Name: ProjectTemplateResourceAssignments
      • Description: Implements extension point global.ProjectTemplateResourceAssginment for running applicable rules on creation of Resource Assignments within Project Templates when applied to a Project.
      • Replace the existing script with the following:

      var ProjectTemplateResourceAssignment = Class.create();

      ProjectTemplateResourceAssignment.prototype = {

      initialize: function() {},

      process: function( /*string*/ projectId, /*string, this param will be available on updating an existing project*/ listOfTaskIds) {

      //Get associated planning item

      var project = new GlideRecord('sn_align_core_project');

      project.addQuery('execution_entity_item', projectId);

      project.query();

      if (project.next())

      var planningItemId = project.getValue('sys_id');

      //Get associated resource assignments

      var g = new GlideRecord('sn_plng_att_core_resource_assignment'),

      objAr = [];

      g.addEncodedQuery('sys_idIN' + JSON.parse(listOfTaskIds));

      g.query();

      //construct object with previous effort + update effort to 0

      while (g.next()) {

      objAr.push({

      'id': g.getUniqueValue(),

      'effort': g.getValue('effort')

      });

      g.effort = 0;

      g.update();

      }

      this.updatePlanningItemFieldOnResourcePlanEntities(projectId, planningItemId);

      //loop through previously constructed array of object(s) and update with actual effort

      if (objAr.length > 1) {

      for (var i in objAr) {

      g.initialize();

      if (g.get(objAr[i].id)) {

      g.effort = objAr[i].effort;

      g.update();

      }

      }

      }

      },

      //bulk updating planning items on Resource Assignments

      updatePlanningItemFieldOnResourcePlanEntities: function(task, planningItem) {

      this._updatePlanningItemFieldforTopTask('sn_plng_att_core_resource_assignment', task, planningItem);

      this._updatePlanningItemFieldforTopTask('resource_plan', task, planningItem, 'resource_type=attribute');

      this._updatePlanningItemFieldforTask('resource_allocation', task, planningItem, 'resource_plan.resource_type=attribute');

      this._updatePlanningItemFieldforTask('sn_plng_att_core_cpaam_effort', task, planningItem);

      },

      _updatePlanningItemFieldforTask: function(table, task, planningItem, encodedQuery) {

      var gr = new GlideRecord(table);

      gr.addQuery('task', task);

      if (!gs.nil(encodedQuery))

      gr.addEncodedQuery(encodedQuery);

      gr.setValue('planning_item', planningItem);

      gr.setWorkflow(false);

      gr.updateMultiple();

      },

      _updatePlanningItemFieldforTopTask: function(table, task, planningItem, encodedQuery) {

      var gr = new GlideRecord(table);

      gr.addQuery('top_task', task);

      if (!gs.nil(encodedQuery))

      gr.addEncodedQuery(encodedQuery);

      gr.setValue('planning_item', planningItem);

      gr.setWorkflow(false);

      gr.updateMultiple();

      },

      type: 'ProjectTemplateResourceAssignment'

      };

    3. Save Script Include

    4. Navigate back to the Extension Point and find the newly created implementation on the Related List.

      This allows for all other Template related Script Includes to run BEFORE the newly added one.

      • Add the ‘Order’ column to the list
      • Update the new ‘ProjectTemplateResourceAssignments’ order to “1000”.
  • Create a Project Template that includes Resource Assignments

    1. Create a new Project in Project Workspace (or use an existing one)
    2. OPTIONAL: Apply an existing Project Template
    3. OPTIONAL: Create new tasks if not applying an existing Project Template
    4. Create ‘Unassigned’ Resource Assignments on the Project Summary Task OR on the applicable Project Tasks
      • Make sure you fill in the Effort type, Effort, and applicable attribute(s) – Group, Role, and/or Skill for each Resource Assignment.
    5. Save the newly created Plan w/ Resource Assignments to a new Project Template
  • Apply the newly created Project Template to a Project

    1. Follow your approved process for applying templates to projects.
  • Configure additional setting - Expose Resource Assignments on Project Tasks

    1. To see Resource Assignments on Project Tasks, the Related List must be added.
      • While on Project Task record (in native UI form), Configure > Related Lists
      • Add the Resource Assignment -> Task to Selected and Save
        JoshSutton_0-1745516957954.png
        JoshSutton_1-1745517027659.png
      • This will be on the Form as well as appear within Project Workspace now
        JoshSutton_0-1745520561592.png
        JoshSutton_2-1745517214455.png
View original source

https://www.servicenow.com/community/spm-articles/including-resource-assignments-within-project-templates/ta-p/3245642