-
Notifications
You must be signed in to change notification settings - Fork 912
Business Service Fetch when CI changes #1739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This code snippet fetches the business service related to the CI , when the CI is changed in the change_request form.
|
Added a client callable Script Include code snippet to fetch business service , when configuration item changes in the change request form. |
WillemZeiler
left a comment
There was a problem hiding this 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"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: '' |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
PR Description:
Pull Request Checklist
Overview
Code Quality
Repository Structure Compliance
Core ServiceNow APIs/Server-Side Components/Client-Side Components/Modern Development/Integration/Specialized Areas/Documentation
Restrictions