About Incident records.

Kentaro Numata
Tera Guru

Hi, I'm Kentaro.

I have a question about Incident records.

 

I want to prevent records from being closed when "Assigned to" is Null.

Therefore, I would like to implement the following functionality.

 

  1. If "Assigned to" is Null when the person in charge posts a comment, a popup will be displayed.
  2. If you select Yes, register the person in charge of posting the comment as "Assigned to".

スクリーンショット 2024-04-22 12.29.51.png

 

I think there is no other way than using "Client Script" and "Script Include".

If there is an easy way to implement it, could you please give me an example?

 

Thanks,

Kentaro.

2 REPLIES 2

Weird
Mega Sage

You can do this by using confirm in a client script.
Basically something like this as a onSubmit client script should work:

 

function onSubmit() {
    if (g_form.getValue('comments') != '' && g_form.getValue('assigned_to') == '') {
        var answer = confirm("Would you like to register yourself as assigned to?");
        if (answer) {
            g_form.setValue('assigned_to', g_user.userID);
        }
    }


}

 

Edit: added check for comments not empty and assigned_to being empty. 

Ankur Bawiskar
Tera Patron
Tera Patron

@Kentaro Numata 

you can use javascript confirm box with Ok and Cancel

If you wish to see Yes, No then you need to use UI page

Sample script using onChange client script on comments

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading) {
		return;
	}

	var answer = confirm("Would you like to register yourself as assigned to?");
	if(answer == true){
		g_form.setValue('assigned_to', g_user.userID);
	} 
}

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