Assistance Required for Pop-Up Window Displaying Incident Details

MaramA
Tera Contributor

Hello,

I wrote the following client script & script include to create a small pop-up window that displays "Details," which is supposed to include the incident fields such as caller, state, and more. However, for some reason, the window shows up blank (as seen in the picture).

I would appreciate your help with this issue.

 

my script include:

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

 

    getIncidentDetails: function() {
        var incidentSysId = this.getParameter('sysparm_incident');
        var incident = new GlideRecord('incident');

 

        if (incidentSysId && incident.get(incidentSysId)) {
            var incidentDetails = {
                number: incident.number.getDisplayValue(),
                short_description: incident.short_description.getDisplayValue(),
                caller_id: incident.caller_id.getDisplayValue()
            };

 

            return JSON.stringify(incidentDetails);
        } else {
            return JSON.stringify({}); // Return empty object if incident not found
        }
    },

 

    type: 'PopUpIncidentDetails' // Specify the type of the Ajax processor

 

});

 

 

my client script:

function onClick(g_form) {

    if (g_form) {

        var uniqueValue = g_form.getUniqueValue();

        if (uniqueValue) {

            var checkIncident = new GlideAjax("PopUpIncidentDetails");

            checkIncident.addParam("sysparm_name", "getIncidentDetails");

            checkIncident.addParam("sysparm_incident", uniqueValue);

            checkIncident.getXMLAnswer(function(response) {

                var incidentDetails = JSON.parse(response);

               

                var detailsChoices = [

                    { label: 'Number: ' + incidentDetails.number, value: incidentDetails.number },

                    { label: 'Short Description: ' + incidentDetails.short_description, value: incidentDetails.short_description },

                    { label: 'Caller: ' + incidentDetails.caller_id, value: incidentDetails.caller_id }

                ];

               

                var fields = [{

                    type: 'choice',

                    name: 'details',

                    label: 'Details',

                    mandatory: true,

                    choices: detailsChoices

                }];

               

                var modalConfig = {

                    title: 'Incident Details',

                    fields: fields,

                    cancelTitle: "Cancel",

                    confirmTitle: "Close",

                    cancelType: "default",

                    size: "md",

                    confirmType: "confirm"

                };

               

                g_modal.showFields(modalConfig).then(function(fieldValues) {

                    var incknowledgeUtil = new GlideAjax("sn_sow_inc.SOWIncidentUtilsAjax");

                    incknowledgeUtil.addParam("sysparm_name", "getIncidentDetails");

                    incknowledgeUtil.addParam("sysparm_incident", uniqueValue);

                    incknowledgeUtil.addParam("details", fieldValues.updatedFields[0].value);

                    incknowledgeUtil.getXML();

                });

            });

        }

    }

}

 

MaramA_0-1720013229802.png

 

2 REPLIES 2

Sanjana8
Kilo Guru

Hi @MaramA 

 

Clicking on which button, you want the above result. Please if you can elaborate the requirement.

MaramA
Tera Contributor

@Sanjana8 
I did create a button at UI Action, the purpose of the button button is to open a small pop-up asking which field from the incident table should be used to create a report with a group by function.