Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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

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

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