- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
If you are planning to make the data structures behind the CSDM available to end users within Task-based forms or develop logic that uses CSDM relationships as part of a CSDM engagement, then you will encounter an gap: in the baseline instance, ServiceNow does not provide any functionality for traversing through and retrieving records based on the relationships that are constructed in CSDM service maps.
So why is this a gap? There are several ways in which you can relate one object or set of objects within a service map to another object or set of objects within CSDM:
- Parent Service of a Service Offering.
- Child Service Offering(s) of a Service.
- Service Offering(s) related to Business App(s) (via App Services).
- Service Offering(s) related to CI(s) (via App Services/Dynamic CI Groups).
- Service Offering(s) related to App Service(s).
- App Service(s) related to Business App(s).
- App Service(s) related to Service Offering(s).
- App Service(s) related to CI(s).
- Dynamic CI Group(s) related to Service Offering(s).
- CI(s) related to Business App(s) (via App Services/Dynamic CI Groups).
- CI(s) related to App Service(s).
- CI(s) related to Service Offering(s) (via App Services/Dynamic CI Groups).
- Business App(s) related to Service Offering(s) (via App Services/Dynamic CI Groups).
- Business App(s) related to App Service(s).
- Business App(s) related to CI(s) (via App Services/Dynamic CI Groups).
The use cases for using these relationships include (but are not limited to):
- Automating population of Reference fields based on values in related CSDM reference fields (e.g., when entering a Service Offering in an Incident, have the parent Service auto-populated).
- Filtering population of Reference fields based on values in related CSDM reference fields (e.g., when entering a Service Offering in an Incident, have the Configuration item field's options limited to those CIs connected to the App Services or Dynamic CI Groups connected to your Service Offering).
- Finding all CIs related to an App Service or a Dynamic CI Group without having to recursively traverse CI Relationships or related query tables on a CMDB Group.
- Related list filtering using a Relationship to return CSDM-related objects.
- Logic to create Task records automatically - (e.g., Flow Designer Flows or Record Producers can contain logic to populate CSDM fields based on a supplied value or values).
So, as there isn't a script include available, I made one: CsdmRelationshipUtils() - which is attached to this blog.
- This is in the Global scope as all of the data it works with is Global and it is just a script, not a scoped app.
- This is server-side only. For client-side processing create a complementary Ajax client-callable script include with wrapper functions that just call the functions in the attached script include to maintain one place for the code. You could edit the baseline "CSDMClientHelper" script include.
- You will need to update the CI Relationships and operational status variables in the initialization function with values from your instance.
- I've used GlideQuery extensively for its better data validation, error reporting and facility to chain functions.
- Each function contains a JSDoc comment. Feel free to refactor with SNDoc or your documentation standard of choice.
- To keep things simple given the many references to a CI, App Service, Service Offering and Business App I've set all variables with the same purpose to the same name.
- I could have used a function to get the tables extended from Automated Business Service, but in Xanadu the Operational Technology System Service class has been added, and as far as I am aware this does not store CI Relationships in the Service Configuration Item Association table.
- Whilst it would be possible to get the values that "hop" across tables using "addJoinQuery", in the spirit of modularizing code I have split each query between a directly-connected pair of CSDM objects into a separate function.
- Each of the functions that need to can accept either a string for a single value, or an array of multiple values, for maximum flexibility.
- This has been tested with a fresh Xanadu PDI and with sample CSDM Service data. I have not included any error logging as this can vary from organization to organization - if for whatever reason nothing is found, then functions will return an empty value (string or array, depending on the function).
- If you find any issues, do let me know and I will fix.
Hopefully such a library will make it into the baseline instance in future. Until then, this might save you some time!
- 1,259 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.