Additional comment mandatory when state is on hold

JordyZ
Mega Sage

Hi,

 

I'd like to have additional comments mandatory when trying to save incident state to on hold. Meaning, it is not possible to save state to on hold unless there's something filled in the additional comments.

 

I have tried this onChange client script from a different thread, but it doesn't work.

Thread: https://www.servicenow.com/community/now-platform-forum/need-logic-to-make-comments-mandatory-when-s...

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    if (newValue == 3) {
        g_form.setMandatory('comments', true);
    }
}

 

What did I do wrong?

1 ACCEPTED SOLUTION

Uncle Rob
Kilo Patron

Are people using a UI Action to move it to On Hold?  Or are they changing the state manually?

If its the latter a UI Policy is the best option for this.  

View solution in original post

5 REPLIES 5

Uncle Rob
Kilo Patron

Are people using a UI Action to move it to On Hold?  Or are they changing the state manually?

If its the latter a UI Policy is the best option for this.  

Veer
Tera Guru

Hello @JordyZ 

Please write the value in quotes 

 

if (newValue == '3')

 

Please Mark this as Accepted Solution / Helpful if it resolves your issue.

 

Deepika18
Tera Guru

Hi @JordyZ ,

 

For this requirement, Scripting is not required. Instead you can use UI Policy.

Please Check the below snapshots. I tried this in my PDI, it is working.

 

UI Policy on incident table and When state is on Hold.

Deepika18_0-1671721464378.png

 

UI Actions : Additional Comments - Mandatory True.

Deepika18_1-1671721586006.png

 

 

Please feel free to ask incase of any queries from the above solution.

Please mark it as correct if it resolved your issue.

 

Regards,

Deepika

 

It is not working. Can you please help me on this?