Do a character count on the Resolution Notes before Resolving

josephd01
Mega Guru

Hi All,

I have requirement to set a default question list for the resolution notes and then doing a character count before the incident is resolved.

 

The default questions on the resolve notes are to be set as : 

Who resolved the call? 

What was done to resolve the call? 

Who verified that it is now working?

 

When the Incident gets resolved it should not have less than 150 characters and should not be the default value to ensure that the agents update the resolution. I found the below script on the community posts.

https://community.servicenow.com/community?id=community_question&sys_id=7f8d5510db7ab810770be6be13961975

This works great if there is no value in the Resolution notes. Is there a way for me to do this? I have not been able to find a solution.

1 ACCEPTED SOLUTION

Hi @josephd01 

Try writing an onSubmit client script as below and check if its working 

function onSubmit() {
   
	var state = g_form.getValue('state');
	if(state == '6')
		{
			if(g_form.getValue('close_notes').toString().length < 150)
				{
					g_form.showErrorBox('close_notes',"Please enter minimum 150 characters");
					return false;
				}
		}
	
	var notes = g_form.getValue('close_notes').toString();
	if((notes.indexOf('Who resolved the call?') == -1)  || (notes.indexOf('What was done to resolve the call?') == -1)  ||  (notes.indexOf('Who verified that it is now working?') == -1) )
		{
			g_form.showErrorBox('close_notes',"Existing value in resolution notes cannot be removed");
			
					return false;
		}
	
}

 

Mark as correct and helpful if it works.

Regards,

Sumanth

View solution in original post

5 REPLIES 5

SumanthDosapati
Mega Sage
Mega Sage

Hi @josephd01 ,

Try this onChange client script on resolution notes field.

function onChange(Control, oldValue, newValue, isLoading) {
if (isLoading || newValue == "") {
return;
}
}
if (newValue.toString().length < 150) { 
g_form.setValue('close_notes','');
alert('Length cannot be less than 150');
}

 

Mark as correct or helpful if it works.

Regards,

Sumanth

@josephd01 

Did you try the above code?

Good Morning,

The issue that I am having is that there is a default value(Set of Questions) that already occupies the field. I need some way to check that the default value was not left without being updated. The solution provided is indeed helpful if there is no value within the field already.

This check only needs to be done when the incident gets resolved.

 

find_real_file.png

Hi @josephd01 

Try writing an onSubmit client script as below and check if its working 

function onSubmit() {
   
	var state = g_form.getValue('state');
	if(state == '6')
		{
			if(g_form.getValue('close_notes').toString().length < 150)
				{
					g_form.showErrorBox('close_notes',"Please enter minimum 150 characters");
					return false;
				}
		}
	
	var notes = g_form.getValue('close_notes').toString();
	if((notes.indexOf('Who resolved the call?') == -1)  || (notes.indexOf('What was done to resolve the call?') == -1)  ||  (notes.indexOf('Who verified that it is now working?') == -1) )
		{
			g_form.showErrorBox('close_notes',"Existing value in resolution notes cannot be removed");
			
					return false;
		}
	
}

 

Mark as correct and helpful if it works.

Regards,

Sumanth