How do you make work notes mandatory when a state changes?

KB30
Tera Expert

I tried to create a UI policy but there is not action for when a state changes. I want to make work notes mandatory when the states changes from on hold to work in progress

9 REPLIES 9

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @KB30 

Try with Client script. 

 

OOTB , when we put INC on hold, additional comments, in same manner we can do our. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

kps sumanth
Mega Guru

Hello @KB30 ,

 

You can try below script in you onChange client script.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '' || g_form.isNewRecord())
		return;
	else if (newValue == oldValue)
		g_form.setMandatory("work_notes", false);
	else if(oldValue ==3 && newValue==2 )
		g_form.setMandatory("work_notes", true);
}

Please mark this helpful and accepted if it worked for you.

Thanks

kps sumanth

How do I add to a UI action I created? I have a UI action button that changes the state to In progress. Script is listed below. I would like to add making worknotes mandatory in this UI action because the client script works separately. 

 

current.incident_state = 2;
current.update();
action.setRedirectURL(current);

Sid_Takali
Kilo Patron

hi @KB30 try this script onChange client script on state field 

if (oldValue == 3 && newValue == 2) {
        g_form.setMandatory('work_notes', true);
    } else {
        g_form.setMandatory('work_notes', false);
    }

 

Please mark my answer Helpful/Correct,

Regards,

Siddharam