Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
How To: Update a cmdb_ci_vm_instance record post-Cloud Provisioning using Policies - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • How To: Update a cmdb_ci_vm_instance record post-Cloud Provisioning using Policies
KB0751397

How To: Update a cmdb_ci_vm_instance record post-Cloud Provisioning using Policies


491 Views Last updated : Apr 8, 2025 public Copy Permalink
KB Summary by Now Assist

Issue

Description


Post-provisioning it may be desirable for to update/modify VM instance (or other) records with custom information as it relates to your business needs. While it may be obvious to create Business Rules for this, it's not immediately clear what to do if information is needed from the Catalog Item when provisioning the cloud resources.

One use case for this would be to assign ownership of a VM to the user group responsible for provisioning it.

Solution


We can accomplish this using a Cloud Policy.

This is easier on London+ due to the "on Catalog item request end" Policy Trigger, which we'll use for this example. The initial steps are to do the following (assuming a basic familiarity with Cloud Policies, see Docs otherwise):

  1. Create new Policy
  2. Set trigger "on Catalog item request end"
  3. Set Blueprint as desired blueprint
  4. Set Operation as "Provision"
    1. Note that if you want this to work on all Blueprints, you leave Blueprint empty. But this means you cannot select the "Provision" operation. Additional code will be required in the Policy Action Script to filter so you aren't executing on other catalog item operations
  5. Create new policy rule to execute a script
  6. Create new Policy Action Script (then set Policy Rule to execute script)
  7. Now modify the script.

When writing a Cloud Policy there are two pertinent variables available to us: "formData" and "current". The formData object contains the data passed from the Blueprint during provisioning and the current object contains the data from the RITM record.

The crux of it can be seen here, but basically clients will need to use either formData or information from the current object to make GlideRecord calls to the records they want to call and then make the desired updates/modifications:

gs.info("formData: " + JSON.stringify(formData));
gs.info("current: " + JSON.stringify(current));

var vmGr = new GlideRecord("cmdb_ci_vm_instance");
vmGr.addQuery("name","=",formData.Virtual_Server_NodeName);
vmGr.query();
if (vmGr.next())
gs.info("vmGr: " + vmGr.sys_id);
else
gs.info("VM record not created at this time: " + new GlideDateTime().getLocalTime());

Applicable Versions


All CMPv2 (easier in London+ due to "on Catalog item request end" option)

 


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.