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.
Multi CDS validators - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • Multi CDS validators
KB0854370

Multi CDS validators


487 Views Last updated : Sep 15, 2023 public Copy Permalink
KB Summary by Now Assist

A Sweagle validation policy (validator) is assigned to at least 1 CDS (the "primary" CDS), but can also work with additional CDS. This allows to create a validation logic which spans configData from multiple CDS. As an example, one could create a validation logic which checks that the dbConnectionString is different in every environment for a given application (in case there is a CDS for every environment).

The content of every assigned CDS is accessible in the parser logic through the variable "metadatasets" (of type array).


the metadatasets variable (type array)


The primary CDS

The primary CDS (to which the validation policy is assigned) is accessible as the first array element, while the additional CDS are sequentially added as the next elements in this array.  Every element in this array is a json object which contains all the nodes and its associated CDIs.


The snapshot content of the primary CDS can be accessed through the metadatasets[0] array's element.


As an example, accessing a CDI which is defined at a node node directly in the root of the CDS snapshot can be done using :

metadatasets[0]["CDSname"]["nodeName"]["CDIkeyName"]

You can also use the dot notation although that is only possible in case there are no . in the nodeNames or keyNames.


The additional CDS

the additional CDS are accessible as subsequent array elements in the metadatasets variable. Additional CDS are added as array elements, starting with index 1 to x, in the sequence in which they have been assigned to the validation rule policy. 

As an example, in case you create a validator which requires exactly 1 additional CDS, you can define a logic which checks that the metadatasets array contains only 2 elements. If not, it will return a controlled script error as a response. 

if (Array.isArray(metadatasets) && metadatasets.length!==2){ 
  return {'result':false,'description':'validation policy error: this validation requires exact 1 primary and 1 additional CDS'}; 
}



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.