Report on reopen reason for incidents

Thereza Van der
Tera Contributor

Hi all

 

Our ServiceDesk need to report on reasons why incidents have been reopened. The reason is saved in the 'additional comments' field, but when I add that to my report, is obviously displays all additional comments. Is there a way to only show the reason for reopening?

 

Thanks

Thereza

 

1 ACCEPTED SOLUTION

Hi @Thereza Van der ,

 

You can create a new field type like string and give some label ,

 

Create a onload client script to hide the field ,

swathisarang98_0-1709629728307.png

 

g_form.setVisible('u_reason_reopen',false);

 

 

In the Ui action you can just add 2 lines of code something like below,

 

 

g_form.setVisible('u_reason_reopen', true);
g_form.setMandatory('u_reason_reopen', true);

 

 

Ui Action Complete code:

 

// Client side onclick function
function reopenIncident() {


    if (g_form.getValue('comments') == '') {
        // Remove any existing field message, set comments mandatory, and show a new field message
        try {
            g_form.hideFieldMsg('comments');
        } catch (e) {}
        g_form.setMandatory('comments', true);
		g_form.setVisible('u_reason_reopen', true);
        g_form.setMandatory('u_reason_reopen', true);
        g_form.showFieldMsg('comments', getMessage('Please enter a comment when reopening an Incident'), 'error');
        return false; // Abort submission
    }
    // Call the UI Action and skip the 'onclick' function
    gsftSubmit(null, g_form.getFormElement(), 'reopen_incident'); // MUST call the 'Action name' set in this UI Action
}

// Code that runs without 'onclick'
// Ensure call to server side function with no browser errors
if (typeof window == 'undefined')
    serverReopen();

function serverReopen() {
    // Set Incident state to active, update and reload the record
    current.incident_state = 2;
    current.state = 2;
    current.update();
    gs.addInfoMessage(gs.getMessage("Incident reopened"));
    action.setRedirectURL(current);
}

 

 

Based on this field create a report

 

Please check and Mark Helpful and Correct if it really helps you.

Regards,

Swathi Sarang

View solution in original post

14 REPLIES 14

Thanks for that, I changed it. So it is hidden now but the UI action is still not working.

 

This is what should happen:

 

If an incident is reopened, it should save the reason reopened in a different field so that I can report on the reason reopened.

 

At the moment is still wants the comments to be saved in the additional comments field instead of the new field I created (reason reopened).

 

Regards

Thereza

Hi @Thereza Van der ,

 

when you click on Reopen incident ui action is it not asking you to Fill reopen reason field ? and yes additional comment will be visible and made mandatory  as it is configured OOB.

 

Thanks 

Swathi 

Thereza Van der
Tera Contributor

No, it does not ask to fill in the reopen reason and that is what I am trying to establish because I need to report on the reason why incidents have been reopened and currently I cannot do that cause the reason gets recorded in the comments field and when trying to report it brings up all the comments and not only the reason why the incident was reopened.

 

Is there any other way to do this?

Then do one more check when you are clicking on Reopen incident note the view on which you are trying and in configure layout for that view check whether you have added the field like whether it is added from left to right in slush bucket ?

 

update the ui action script as below,

// Client side onclick function
function reopenIncident() {
    if (g_form.getValue('comments') == '' || g_form.getValue('u_reason_reopen') == '') {
        // Remove any existing field message, set comments mandatory, and show a new field message
        try {
            g_form.hideFieldMsg('comments');
        } catch (e) {}
        g_form.setMandatory('comments', true);
        g_form.setVisible('u_reason_reopen', true);
        g_form.setMandatory('u_reason_reopen', true);
        g_form.showFieldMsg('comments', getMessage('Please enter a comment when reopening an Incident'), 'error');
        return false; // Abort submission
    }
    // Call the UI Action and skip the 'onclick' function
    gsftSubmit(null, g_form.getFormElement(), 'reopen_incident'); // MUST call the 'Action name' set in this UI Action
}

// Code that runs without 'onclick'
// Ensure call to server side function with no browser errors
if (typeof window == 'undefined')
    serverReopen();

function serverReopen() {
    // Set Incident state to active, update and reload the record
    current.incident_state = 2;
    current.state = 2;
    current.update();
    gs.addInfoMessage(gs.getMessage("Incident reopened"));
    action.setRedirectURL(current);
}

Thereza Van der
Tera Contributor

Hi Swathi

 

Screenshots attached. It still jumps to additional comments when clicking on reopen incident.