How to make suspend reasons mandatory on click of suspend button?

ankitkathuria
Tera Contributor

Requirement: For parent work order, suspended reasons field (sla_suspended_reason) should be mandatory at the time of clicking suspend button.

 

UI Action Script:

 

if (current.work_notes != '') {
    new StateFlow().processFlow(current, '7e82e738d7230100fceaa6859e61037d', 'manual');
} else {
    //current.setMandatory('sla_suspended_reason', true);
    gs.addErrorMessage(gs.getMessage('Provide a reason for suspension in Work notes'));
}
8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@ankitkathuria 

this is an OOB UI action

You cannot make it mandatory using server side.

You will have to make it client + server

if (current.work_notes != '') {
    new StateFlow().processFlow(current, '7e82e738d7230100fceaa6859e61037d', 'manual');
} else {
    gs.addErrorMessage(gs.getMessage('Provide a reason for suspension in Work notes'));
}

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

Can you provide the code and steps? @Ankur Bawiskar 

@ankitkathuria 

why to update OOB UI action?

I won't recommend that.

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

I want to make field mandatory on click of UI Action, would clone this UI action but would need help in code @Ankur Bawiskar