Autopopulate Watchlist users in incident form

Servicenow de11
Tera Contributor

Hello,

 

I have a requirement that is, we have field called 'SHOW'(Reference field) in incident form. If the user selects 'Primer Impacto'  show then  'example@test.com' user should be autopopulate in Watchlist. Attached screenshot

Can anyone please suggest the script to achieve this.

 

Thanks in advance

1 ACCEPTED SOLUTION

@Servicenow de11 

your script is wrong.

do this

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

	var val = g_form.getDisplayBox('u_show').value; // give here the field name
	// give here correct choice values
	if (val == "Primer Impacto") {
		g_form.setValue('watch_list', 'sysIdOfUser'); // give here the sys_id of the user you want to set in watch list
	}
}

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

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Servicenow de11 

so you need to write onChange client script.

where are you stuck?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Attached screenshot

Servicenowde11_1-1694608689490.png

 

 

 

 

@Servicenow de11 

your script is wrong.

do this

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

	var val = g_form.getDisplayBox('u_show').value; // give here the field name
	// give here correct choice values
	if (val == "Primer Impacto") {
		g_form.setValue('watch_list', 'sysIdOfUser'); // give here the sys_id of the user you want to set in watch list
	}
}

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