Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

Populate stack name with a script

This example illustrates how to populate the name of the stack that a user requests from the Cloud Provisioning and Governance catalog by utilizing the user's ID. The example uses a script include that you can call from a blueprint rule action.

Before you begin

Role required: sn_cmp.cloud_service_designer

Before you can follow this example, you should be familiar with creating blueprints and blueprint rules. See these resources:

This example uses a script include. If you want to create similar script includes, familiarize yourself with the Glide System APIs that are part of your instance. See the Developer site for a comprehensive list of all APIs. See Script Includes for more information about how the system uses these scripts.

About this task

The goal of this example is to take the ID of the catalog requester and populate it in the Stack Name field. The field remains editable. Follow an example like this one when you want to loosely enforce a naming or labeling convention on certain values, but still allow the user to enter the text that they want.

Procedure

  1. Create a script include that returns the user ID of the person requesting the catalog item:

    1. In the standard interface for the instance (not in the Cloud Admin Portal), click the gear icon (
Image omitted: icon-gear-system-settings.png
System settings gear icon\) in the upper left, and then click **Developer**.
2.  In the **Application** field, select **Cloud Provisioning and Governance**.
Image omitted: scope-cmp.png
Changing the scope
    The application scope of your instance changes to**Cloud Provisioning and Governance**. This selection means that the Cloud Provisioning and Governance application can find the script include.

3.  Close the System Settings window.

4.  Navigate to **System Definition** > **Script Includes**.

5.  Click **New**.

6.  Fill in the form fields \(see table\):
FieldDescription
NameProvide a descriptive name without spaces.
Accessible fromSelect All application scopes.
ScriptEnter this script:
var SetFields = Class.create();
SetFields.prototype = {
    initialize: function() {
    },
    setStackName: function(){
        return gs.getUserName();
    },
    type: 'HideFormAttributes'
};
The function `setStackName()` returns the user name of the catalog item requester. You can call this function from a blueprint rule action.
Image omitted: blueprint-setfields-scriptinclude.png
Set fields script include
7.  Click **Submit**.

8.  Click the gear icon \(
Image omitted: icon-gear-system-settings.png
System settings gear icon\) in the upper left again, and then change the **Application** back to **Global**.
  1. In the Cloud Admin portal, navigate to Design > Blueprints and open the relevant blueprint.

  2. On the blueprint form, click the Catalog tab, and then click the tile that represents the Provision operation.

Image omitted: request-operation-catalog-item.png
Catalog item
  1. Click the Stack Name variable set in the Variable Sets related list.

    Notice that Stack Name is a single line text field that takes text input.

  2. Create a rule to populate the stack name:

    1. Scroll down to the bottom of the form and click New in the Rules related list.

    2. Provide a name and description.

    3. Click Submit.

  3. Configure the action as follows:

    1. From the Rule form, scroll down and click New in the Action related list.

    2. Configure the rule as follows:

FieldDescription
NameProvide a meaningful name and description, such as `Set Stack Name to User ID`.
Action TypeSelect SetValueByScript to tell the system to call the script include that you specify in the Value field.
Target VariableSelect StackName to tell the system to set the value of the Stack Name field.
ValueCall the method in the script include that returns the user ID. The call must be in the following syntax:`$(Script:ScriptIncludeName.methodName[])` In this example, use `$(Script:SetFields.setStackName[])`
Image omitted: blueprint-action-pop-stackname.png
A script action on StackName
3.  Click **Submit**.

Result

In the Cloud User Portal, the catalog order form for the Provision operation shows the user ID of the logged-in user. This example uses the user Able Tutor, which comes in the base system as demo data. The value in the Stack Name field is the same value as in the User ID field on the User [sys_user] table. The profile icon for the same logged in user is also displayed in the upper right of the Cloud User Portal.

Image omitted: logged-in-user.png
The Logged In User

Parent Topic:Cloud catalog form configuration examples