{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":29278,"path":"it-operations-management/cloud-configuration-governance/use-case-resource-pool.md","title":"Example resource pool that limits choices to cost center","bundle":null,"doc_type":null,"release":"australia","body":"\n# Example resource pool that limits choices to cost center\n\nYou can use resource pools with blueprints to limit the choices on the cloud catalog request form.\n\n## Use case: Restrict cost center selection\n\nIn 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.\n\n## Assumptions\n\n-   The Cost Management \\[con.snc.cost\\_management\\] plugin is active.\n-   Cost centers are defined and users are associated with the cost centers.\n-   At least one blueprint is defined. This example uses a blueprint named **AWS Virtual Server**.\n-   You are assigned the sn\\_cmp\\_cloud\\_admin role and know JavaScript and JSON scripting.\n\n## Components\n\n-   **Review resource pool filter**\n    1.  On the Cloud Admin portal navigate to **Manage** &gt; **Resource Pools**.\n    2.  Open the **CostCenterPool** and review the related Resource Pool Filters.\n\n        -   **All** is a query filter that returns all cost centers in the table.\n        -   **UserCostCenter** is a script filter that looks up the cost center associated with the user who is ordering the item.\n        Here is the script for the **UserCostCenter** filter:\n\n        ```\n        getFilteredRecords();\n        //Do not remove function declaration\n        /**\n        * @returns filtered records in the format [{\"value\"=\"lookupValue\",label=\"displayValue\"}]\n        */\n        function getFilteredRecords() {\n        \tvar filteredRecords = [];\n        \tvar userId = gs.getUserID();\n        \tvar userGr = new GlideRecord('sys_user');\n        \tif (userGr.get(userId)){\n        \t\tvar costCenterId = userGr.getValue('cost_center');\n        \t\tif (costCenterId){\n        \t\t\tvar costCenterGr = new GlideRecord('cmn_cost_center');\n        \t\t\tif (costCenterGr.get(costCenterId)){\n        \t\t\t\tvar costCenter = {};\n        \t\t\t\tcostCenter.value = costCenterGr.getUniqueValue();\n        \t\t\t\tcostCenter.label = costCenterGr.getValue('name');\n        \t\t\t\tfilteredRecords.push(costCenter);\n        \t\t\t}\n        \t\t}\t\t\n        \t}\n        \n        \t//force to string\n        \treturn new global.JSON().encode(filteredRecords);\n        }\n        ```\n\n-   **Blueprint catalog form parameters**\n    1.  Navigate to **Design** &gt; **Blueprints**, and then click the tile for the blueprint you want to open.\n    2.  With the blueprint in **Draft** state, click the **Provision** operation tile on the **Catalog** &gt; **Request Operation** tab.\n\n        \\[Omitted image \"provision-operation-blueprint.png\"\\] Alt text: Provision operation\n\n    3.  In the Variable sets related list, click the **General Info** variable set. By default, the CostCenter variable is in this variable set.\n    4.  In the Cloud Variables related list on the Variable Set form, click the **CostCenter** variable.\n\n        \\[Omitted image \"costcenter-variabe.png\"\\] Alt text: CostCenter variable\n\n    5.  On the Cloud Variable form, click the **Type Specifications** tab.\n    6.  Look at the **Pool** and **Pool Filter** fields that refer to the resource pool and filter.\n\n        -   **CostCenterPool** is the name of the resource pool.\n        -   **UserCostCenter** is the filter script that pulls in the cost center options for the user to select from.\n        \\[Omitted image \"bp-prop-datasource-pool.png\"\\] Alt text: Resource pool and filter used in the datasource value of the cost center catalog property\n\n    7.  Set the blueprint to **Published**.\n-   **Cost center user**\n\n    Identify a user who is a member of a cost center and who has access to the Cloud User Portal.\n\n    \\[Omitted image \"cost-center-user.png\"\\] Alt text: User who is a member of the sales cost center.\n\n\n## Testing the resource pool filter\n\nAfter reviewing the components that comprise this use case, test the cloud catalog item to verify that users can select only their cost center.\n\n1.  Impersonate the user, **Alene Rabeck** in this example.\n2.  On the Cloud User Portal, click **Launch a Stack**, and then select the cloud catalog item \\(**AWS Virtual Server** in this example\\).\n3.  Review the selections in the **Cost Center** list.\n\n    \\[Omitted image \"catalog-item-cost-center-choice.png\"\\] Alt text: Sales is the only selection for this user's cost center.\n\n\nWith 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.\n\n## Changing the resource pool filter\n\nTest that the resource pool filter is controlling the behavior of the **Cost Center** field by changing it and viewing the results.\n\n1.  On the Cloud Admin Portal, navigate to **Design** &gt; **Blueprints** and then click **AWS Virtual Server**.\n2.  Click the **Provision** operation tile.\n3.  In the Variable sets related list, click the **General Info** variable set. By default, the CostCenter variable is in this variable set.\n4.  In the Cloud Variables related list on the Variable Set form, click the **CostCenter** variable.\n5.  On the Cloud Variable form, click the **Type Specifications** tab.\n6.  Edit the **Pool filter** field to change the filter from **UserCostCenter** to **All**.\n\n    \\[Omitted image \"bp-prop-datasource-pool-all.png\"\\] Alt text: Resource pool and filter used in the datasource value of the cost center catalog property\n\n7.  Click **Update**, then click**Publish.**.\n8.  Impersonate the user, **Alene Rabeck** in this example.\n9.  On the Cloud User Portal, launch a stack, and then select **AWS Virtual Server**.\n10. Verify that all cost centers are listed.\n\n    \\[Omitted image \"catalog-item-cost-centers.png\"\\] Alt text: All cost centers are now displayed for selection.\n\n\n"}}