Create a policy script

You can write a script to use in policies. Associate these scripts in policy actions.

Before you begin

Role required: sn_cmp.cloud_governor

About this task

You can use these scripts to manipulate form data or to generate a random number. Other attribute changes are ignored. User data cannot be overwritten with scripts, but is available to use in script conditions. You cannot edit scripts for policies that are in the Published state. Click Edit to make the policy go into a draft mode. After making the required changes, publish the policy again.


  1. Navigate to Cloud Management > Cloud Admin Portal > Manage > Policies > Policy Action Scripts .
  2. In the Policy Rule Action Scripts related list, click New.
  3. Fill out the form fields (see table).
    Field Description
    Name Enter a descriptive name. After you enter a name, a script appears with a variable that uses the name that you entered.
    Description Provide a description for what this script does.
    Action Script Category Choose another category or keep the one you created in an earlier step.
    Script Modify the customScripts function in the script.
  4. Click Submit.


The following is an example script that overrides an application server node name value submitted by a user with the value MyNodeName when the user belongs to a user group:
customScript : function( formData){
  var groups = this.parameters.userData.groups; 
    if( groups.length > 0){ 
      formData.App_Server_NodeName = "MyNodeName"; 
  return formData;

This example turns a random number:

customScript : function( formData){
  var min = 10000;
  var max = 99999;
  var num = Math.floor(Math.random() * (max - min + 1)) + min;
  formData.randomNumber = num + "";  
  return formData;