Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Show and Hide a list

rampage
Tera Contributor

how to display the list of child incidents only on parent incidents.

and hide the list of child incidents on non parent incidents.

1 ACCEPTED SOLUTION

Tai Vu
Kilo Patron
Kilo Patron

Hi @rampage 

Let's try below approach.

1. Create a Client Callable Script Include to validate if the current record is a parent incident.

Sample below

var CLIncidentUtils = Class.create();
CLIncidentUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	isParentIncident: function(){
		var incidentID = this.getParameter('sysparm_incident_id');
		var grIncident = new GlideRecord('incident');
		grIncident.addQuery('parent_incident', incidentID);
		grIncident.query();
		return grIncident.hasNext();
	},

    type: 'CLIncidentUtils'
});

 

2. Create OnLoad Client Script to hide the Related List Child Incidents accordingly.

function onLoad() {
    var ga = new GlideAjax('global.CLIncidentUtils');
    ga.addParam('sysparm_name', 'isParentIncident');
    ga.addParam('sysparm_incident_id', g_form.getUniqueValue());
    ga.getXMLAnswer(function(response) {
		alert(response);
        if (!response) {
            g_form.hideRelatedList('incident.parent_incident');
        }
    });
}

 

Let me know if it works for you.

 

Cheers,

Tai Vu

View solution in original post

2 REPLIES 2

Tai Vu
Kilo Patron
Kilo Patron

Hi @rampage 

Let's try below approach.

1. Create a Client Callable Script Include to validate if the current record is a parent incident.

Sample below

var CLIncidentUtils = Class.create();
CLIncidentUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	isParentIncident: function(){
		var incidentID = this.getParameter('sysparm_incident_id');
		var grIncident = new GlideRecord('incident');
		grIncident.addQuery('parent_incident', incidentID);
		grIncident.query();
		return grIncident.hasNext();
	},

    type: 'CLIncidentUtils'
});

 

2. Create OnLoad Client Script to hide the Related List Child Incidents accordingly.

function onLoad() {
    var ga = new GlideAjax('global.CLIncidentUtils');
    ga.addParam('sysparm_name', 'isParentIncident');
    ga.addParam('sysparm_incident_id', g_form.getUniqueValue());
    ga.getXMLAnswer(function(response) {
		alert(response);
        if (!response) {
            g_form.hideRelatedList('incident.parent_incident');
        }
    });
}

 

Let me know if it works for you.

 

Cheers,

Tai Vu

rampage
Tera Contributor

I made a small change, if (response == 'false') and it worked perfectly...THANK U SO MUCH