Skip to content

Conversation

@SaiSankar1309
Copy link
Contributor

@SaiSankar1309 SaiSankar1309 commented Oct 3, 2025

PR Description:

Pull Request Checklist

Overview

  • I have read and understood the CONTRIBUTING.md guidelines
  • My pull request has a descriptive title that accurately reflects the changes
  • I've included only files relevant to the changes described in the PR title and description
  • I've created a new branch in my forked repository for this contribution

Code Quality

  • My code is relevant to ServiceNow developers
  • My code snippets expand meaningfully on official ServiceNow documentation (if applicable)
  • I've disclosed use of ES2021 features (if applicable)
  • I've tested my code snippets in a ServiceNow environment (where possible)

Repository Structure Compliance

  • I've placed my code snippet(s) in one of the required top-level categories:
    • Core ServiceNow APIs/
    • Server-Side Components/
    • Client-Side Components/
    • Modern Development/
    • Integration/
    • Specialized Areas/
  • I've used appropriate sub-categories within the top-level categories
  • Each code snippet has its own folder with a descriptive name

Documentation

  • I've included a README.md file for each code snippet
  • The README.md includes:
    • Description of the code snippet functionality
    • Usage instructions or examples
    • Any prerequisites or dependencies
    • (Optional) Screenshots or diagrams if helpful

Restrictions

  • My PR does not include XML exports of ServiceNow records
  • My PR does not contain sensitive information (passwords, API keys, tokens)
  • My PR does not include changes that fall outside the described scope

This code snippet fetches the business service related to the CI , when the CI is changed in the change_request form.
@WillemZeiler WillemZeiler self-assigned this Oct 3, 2025
@SaiSankar1309
Copy link
Contributor Author

Added a client callable Script Include code snippet to fetch business service , when configuration item changes in the change request form.

Copy link
Contributor

@WillemZeiler WillemZeiler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. However, it doesn’t comply with our contributing guidelines. As a reminder, the general requirements (as outlined in the CONTRIBUTING.md file).
I have added comments in the code. In general consider using meaningful variable names and include (more) comments in the code, that will help readability. For specifics on CSDM, feel free to reach out if you need help on ideation! :)
Review your contribution against the guidelines and make the necessary adjustments. Closing this for now. Once you make additional changes, feel free to re-open this Pull Request or create a new one.

ga.getXML(callScriptInclude);

function callScriptInclude(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not handle the response. The description says it will filters business services (line 6 of the description). This is not done in this script.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Willem,
My apologies, I missed to handle the response . This has been corrected.

gs.log('GetServiceDetails called for CI: ' + ciSysId);

var result = {
businessService: ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You define businessService, but later on use businessServiceId and businessServiceName. Please define the right variables and check for unused ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have taken only business service name into account.

rel.addQuery('child', ciSysId);
rel.query();
if (rel.next()) {
var bs = new GlideRecord('cmdb_ci_service');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not take into account CI groups. Consider expanding this to support a CSDM aligned setup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I’ve kept the logic focused on direct CI-to-Business Service relationships via cmdb_rel_ci, just to keep it simple and testable. I haven’t incorporated CI Groups or Application Services yet, but I agree that expanding toward a full CSDM model would make this more robust. I appreciate you remarks and revisit it once the base functionality is validated.
I’ll mark this as a potential enhancement . Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants