The CreatorCon Call for Content is officially open! Get started here.

Remove OOTB messages on state transition on a problem

KimAlsgaard
Tera Contributor

Hi all,

 

I have a requirement to show a friendly user message, if a user is not permitted to move a problem from state resolved to closed. There is a quality assurance check, so only those with the role "problem_manager" must be able to move from resolved to closed.

 

On the image below I have added a message in a user friendly language. Is it possible to remove the other two messages, so only mine is shown to the user?

 

KimAlsgaard_0-1755861019336.png

 

 

I have tried to add a business rule to run before update with this condition: previous.state == 106 && current.state == 107 && !gs.hasRole('problem_manager') but it doesn't work (nevermind the "technical lead", that's for non-major problems). It still show the OOTB messages.

 

(function executeRule(current, previous /*null when async*/) {
    var user = gs.getUser();
    var isProblemManager = user.hasRole('problem_manager');
    var isTechLead = ((user.getRecord().getValue('title') || '').toLowerCase() == 'technical lead');

    var stateWasResolved = (previous.state == 6); // Resolved
    var stateIsClosed = (current.state == 7);     // Closed

    if (stateWasResolved && stateIsClosed) {
        if (current.major_problem == true || current.major_problem == 'true' || current.major_problem == 1) {
            if (!isProblemManager) {
                gs.addErrorMessage('Only Problem Managers can close a Major Problem.');
                current.setAbortAction(true);  // blocks transition
            }
        } else {
            if (!(isTechLead || isProblemManager)) {
                gs.addErrorMessage('Only Technical Leads or Problem Managers can close this Problem.');
                current.setAbortAction(true);  // blocks transition
            }
        }
    }
})(current, previous);

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@KimAlsgaard 

You cannot suppress those OOTB messages as they come from platform level.

With your new business rule as well it won't work.

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

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

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@KimAlsgaard 

You cannot suppress those OOTB messages as they come from platform level.

With your new business rule as well it won't work.

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

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

Thanks, so at least I won't have to pull off any more grey hairs over this 🙂