show/hide form section on change request form if the caused by change field on incident is populated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 11:55 PM
Hi All,
I hope you are well, I am new to scripting in SNOW and have a interesting use case. The Change Management team run post implementation reviews on changes that cause incident(s). please keep in mind im doing all of this in a PDI.
what we have is:
a "failed change review" section on the change_request form with custom fields and related lists (screenshot below)
what is needed is:
when the "caused by change" field on the INCIDENT form is initially set or updated, look up field and show the "failed change review" section on the corresponding change_request form but if the caused by change field is empty then dont show "failed change review" tab on change request form,
Example:
ie. if CHG0000030 caused 3 incidents the show the "failed change review" section on the change_request form if not then hide it.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2024 12:11 AM
For one: if you are using SNOW, you are on the wrong community, because SNOW is a completely different platform than ServiceNow.
But since your question does look ServiceNow related: you can hide sections through client scripts (https://www.servicenow.com/community/now-platform-forum/show-hide-form-section-using-client-script/m...) or use a scripted ui policy.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2024 03:59 AM
Hi Mark,
apologies please forgive my ignorance, yes my query is related to ServiceNow, specifically a client script to hide a form section based on value in another table, the info in the link partially answers my question, I just need to answer the part of how we lookup the "caused by incident" field on the incident form.
if this forum is not meant to be a technical forum for sys admins I will try find another forum to post on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2024 11:13 PM
This should give you a start:
onLoad client script:
function onLoad() {
function hideSectionIfCausedByChange() {
var ga = new GlideAjax('IncidentCausedByChangeChecker');
ga.addParam('sys_id', g_form.getUniqueValue());
ga.getXMLAnswer(function(response) {
var isCausedByChange = response.responseXML.documentElement.getAttribute("answer") === 'true';
if (isCausedByChange) {
g_form.setSectionDisplay('section_name', false); //replace with the name of the section you want to hide
}
});
}
hideSectionIfCausedByChange();
}
Client callable script include:
var IncidentCausedByChangeChecker = Class.create();
IncidentCausedByChangeChecker.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isCausedByChange: function() {
var changeId = this.getParameter('sys_id');
var incidentGR = new GlideRecord('incident');
incidentGR.addQuery('caused_by_change', changeId);
incidentGR.query();
if (incidentGR.next()) {
return 'true';
}
return 'false';
}
});
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 01:30 AM
thanks heaps for your help Mark, I will give it a go.