Example resource pool that limits choices to cost center

  • Release version: Zurich
  • Updated July 31, 2025
  • 3 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Example resource pool that limits choices to cost center

    This example demonstrates how to use resource pools with blueprints in ServiceNow to restrict cloud catalog request form options based on a user’s cost center. The goal is to ensure that cloud asset costs are charged to the appropriate cost center budget by limiting users to selecting only their associated cost center when ordering cloud resources.

    Show full answer Show less

    Key Features

    • Resource Pool Filters: Two key filters are used:
      • All: Returns all cost centers.
      • UserCostCenter: A scripted filter that dynamically retrieves the cost center linked to the ordering user, ensuring selection is limited to their cost center.
    • Blueprint Integration: The blueprint’s request form variables can reference the resource pool and filter, specifically setting the CostCenter variable to use the UserCostCenter filter.
    • Script Example: The UserCostCenter filter script uses GlideRecord to find the user’s cost center and returns it in a JSON-encoded list for form selection.
    • Testing and Validation: By impersonating a user with a cost center association, users can verify that only their cost center appears as a selectable option on the Cloud User Portal catalog item.

    How to Apply and Customize

    • Prerequisites: Ensure the Cost Management plugin is active, cost centers and user associations exist, and relevant blueprints are defined.
    • Configuring the Blueprint: Edit the blueprint’s Provision operation variables to set the CostCenter variable’s pool and pool filter to use CostCenterPool and UserCostCenter, respectively.
    • Customizing Resource Pool Filters: Modify the pool filter script or switch filters (e.g., from UserCostCenter to All) to control which cost centers appear on the request form.
    • Publishing Changes: After edits, publish the blueprint to apply changes.

    Expected Outcomes

    • Users are restricted to selecting only their associated cost center when ordering cloud resources, ensuring accurate cost allocation.
    • Administrators have flexibility to modify filters to broaden or narrow cost center visibility as needed.
    • Improved governance and budget control over cloud resource consumption via cost center-based restrictions directly in ServiceNow’s Cloud Management interface.

    You can use resource pools with blueprints to limit the choices on the cloud catalog request form.

    Use case: Restrict cost center selection

    In this example, the cost of the cloud asset is charged against the budget of the cost center of the user. The base-system UserCostCenter resource pool ensures that a user can select only resources in their cost center.

    Assumptions

    • The Cost Management [con.snc.cost_management] plugin is active.
    • Cost centers are defined and users are associated with the cost centers.
    • At least one blueprint is defined. This example uses a blueprint named AWS Virtual Server.
    • You are assigned the sn_cmp_cloud_admin role and know JavaScript and JSON scripting.

    Components

    Review resource pool filter
    1. On the Cloud Admin portal navigate to Manage > Resource Pools.
    2. Open the CostCenterPool and review the related Resource Pool Filters.
      • All is a query filter that returns all cost centers in the table.
      • UserCostCenter is a script filter that looks up the cost center associated with the user who is ordering the item.
      Here is the script for the UserCostCenter filter:
      getFilteredRecords();
      //Do not remove function declaration
      /**
      * @returns filtered records in the format [{"value"="lookupValue",label="displayValue"}]
      */
      function getFilteredRecords() {
      	var filteredRecords = [];
      	var userId = gs.getUserID();
      	var userGr = new GlideRecord('sys_user');
      	if (userGr.get(userId)){
      		var costCenterId = userGr.getValue('cost_center');
      		if (costCenterId){
      			var costCenterGr = new GlideRecord('cmn_cost_center');
      			if (costCenterGr.get(costCenterId)){
      				var costCenter = {};
      				costCenter.value = costCenterGr.getUniqueValue();
      				costCenter.label = costCenterGr.getValue('name');
      				filteredRecords.push(costCenter);
      			}
      		}		
      	}
      
      	//force to string
      	return new global.JSON().encode(filteredRecords);
      }
    Blueprint catalog form parameters
    1. Navigate to Design > Blueprints, and then click the tile for the blueprint you want to open.
    2. With the blueprint in Draft state, click the Provision operation tile on the Catalog > Request Operation tab.

      Provision operation

    3. In the Variable sets related list, click the General Info variable set. By default, the CostCenter variable is in this variable set.
    4. In the Cloud Variables related list on the Variable Set form, click the CostCenter variable.

      CostCenter variable

    5. On the Cloud Variable form, click the Type Specifications tab.
    6. Look at the Pool and Pool Filter fields that refer to the resource pool and filter.
      • CostCenterPool is the name of the resource pool.
      • UserCostCenter is the filter script that pulls in the cost center options for the user to select from.

      Resource pool and filter used in the datasource value of the cost center catalog property

    7. Set the blueprint to Published.
    Cost center user
    Identify a user who is a member of a cost center and who has access to the Cloud User Portal.

    User who is a member of the sales cost center.

    Testing the resource pool filter

    After reviewing the components that comprise this use case, test the cloud catalog item to verify that users can select only their cost center.

    1. Impersonate the user, Alene Rabeck in this example.
    2. On the Cloud User Portal, click Launch a Stack, and then select the cloud catalog item (AWS Virtual Server in this example).
    3. Review the selections in the Cost Center list.

      Sales is the only selection for this user's cost center.

    With the CostCenterPool::UserCostCenter datasource value for this catalog item, the only option for the Cost Center is the cost center the user is a member of.

    Changing the resource pool filter

    Test that the resource pool filter is controlling the behavior of the Cost Center field by changing it and viewing the results.

    1. On the Cloud Admin Portal, navigate to Design > Blueprints and then click AWS Virtual Server.
    2. Click the Provision operation tile.
    3. In the Variable sets related list, click the General Info variable set. By default, the CostCenter variable is in this variable set.
    4. In the Cloud Variables related list on the Variable Set form, click the CostCenter variable.
    5. On the Cloud Variable form, click the Type Specifications tab.
    6. Edit the Pool filter field to change the filter from UserCostCenter to All.

      Resource pool and filter used in the datasource value of the cost center catalog property

    7. Click Update, then clickPublish..
    8. Impersonate the user, Alene Rabeck in this example.
    9. On the Cloud User Portal, launch a stack, and then select AWS Virtual Server.
    10. Verify that all cost centers are listed.

      All cost centers are now displayed for selection.