Is it possible to make Comments mandatory on incident form of service portal while reopening the inc

SandeshB
Tera Contributor

Hi there,

 

I have a requirement to make comments mandatory if end user tries to reopen the incident by using "Reopen" ui action on service portal.

SandeshB_0-1757786509101.png

 

 

Is it feasible to achieve? if yes the how? if not, could you please share any servicenow document stating the same?

 

Thank!

6 REPLIES 6

This is from the OOB UI Action named "Reopen" defined on the incident table:

 

// Client side onclick function
function reopenIncident() {
    if (g_form.getValue('comments') == '') {
        g_form.setMandatory('comments', true);
    }
    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();
    var msg;
    if (current.child_incidents > 0) {
        msg = gs.getMessage("{0} and its child incident(s) have been reopened", current.getDisplayValue());
    } else {
        msg = gs.getMessage("{0} has been reopened", current.getDisplayValue());
    }
    gs.addInfoMessage(msg);
    action.setRedirectURL(current);
}

Ankur Bawiskar
Tera Patron

@SandeshB 

this link has solution for portal, check and enhance as per your requirement

Create Reopen Incident Widget which requires comments for Service Portal 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader