Make "On Hold Reason" Mandatory for Multiple Incident State Selection in List View

LokeshwarRV
Tera Contributor

Hi Community,

I'm working on a requirement where we need to enforce the "On Hold Reason" field as mandatory when multiple incidents are updated to the "On Hold" state from the list view. and also for single selection

Here’s the specific scenario:

  • When users select multiple incidents in the list view and change the Incident State to "On Hold", the "On Hold Reason" field should become a mandatory field before the update is allowed.
  • This should apply consistently across all incidents being updated in bulk.

Has anyone implemented a similar validation or can suggest the best approach to achieve this? Would a UI Policy or a Client Script work in list view bulk updates, or is a different method required?

Any guidance or examples would be greatly appreciated!

Thanks in advance,

LokeshwarRV_0-1754425346264.png

 





3 REPLIES 3

Rafael Batistot
Kilo Patron

Hi @LokeshwarRV 

May you try  use a Before Update Business Rule

  • Name: Enforce On Hold Reason
  • Table: incident

  • When: before

  • Update: yes

  • Insert: no

  • Advanced:  (check this to use script)

var STATE_ON_HOLD = 3;
    if (current.state == STATE_ON_HOLD && previous.state != STATE_ON_HOLD) {

        // Check if On Hold Reason is empty
        if (!current.hold_reason) {
            gs.addErrorMessage("On Hold Reason is required when setting the state to 'On Hold'.");
            current.setAbortAction(true); // prevent the update
        }
    }


you can cosider too a client script onChange


Example of onChange Client Script (form view)

Client Script Configuration:

  • Type: onChange

  • Table: incident

  • Field: state

Script:

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    var ON_HOLD_STATE = '3'; // On Hold
    if (newValue == ON_HOLD_STATE) {
        g_form.setMandatory('hold_reason', true);
    } else {
        g_form.setMandatory('hold_reason', false);
    }
}




 

Its not working

Ankur Bawiskar
Tera Patron
Tera Patron

@LokeshwarRV 

you will have to use before update business rule for this.

What did you try so far and what didn'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