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

swathisarang98
Giga Sage
Giga Sage

Hi @Thereza Van der ,

 

Based on Additional comment or worknote this is not possible, you can create a new field to capture the reason for reopening the incident and report on that field.

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

Thereza Van der
Tera Contributor

Morning Swathi 🙂

 

Thanks for the reply. I was thinking about a separate field, but was not sure how to get it to use that field instead of the additional comments field. Can I just copy the script and create another UI Action, and replace the 'comments' with the new field name?

 

I do not know scripting but logic tells me if it works as is, I can just replace the field name?

 

TherezaVander_0-1709625259992.png

 

This is the script:

 

// 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.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);
}

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

Perfect ... Perfect ... Perfect!!!

 

THANKS FOR ASSISTING ME, MUCH APPRECIATED! I learnt a lot from you today.

 

Regards

t