Clear Assigned to value on change of Assignment Group

lucky6
Tera Contributor

Hi,

After changing of Assignment Group" , Assigned to field should be clear. How can i achieve this with below scriptings.

1.Client Script

2.Business Rule

 I tried Onchnage Client script but it is not working

11 REPLIES 11

Mark Roethof
Tera Patron
Tera Patron

Hi there,

If this should happen onChange, then it's Client Side scripting. You could use a onChange client script (onChange of Assignment Group) for this, which simply applies something like:

g_form.setValue('assigned_to', '');

For some field types clearValue will also work, though from the top of my mind, this doesn't work for a reference field.

In some cases, when Assigned to is depending on Assignment group, it's already cleared.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

i tried the same script but still it is not working..

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

g_form.setValue('assigned_to', '');

}

Can you share some screenshots? For example it could be that the UI Type field is wrong. Is it onChange of Assignment Group?

You might also add some debugging, start your script with an alert of addInfoMessage, to see if your script got triggered. (or if you are familiar with using the console, console.log might help)

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Jaspal Singh
Mega Patron
Mega Patron

Hi Lucky,

 

Apporach shared by Mark should work. In addition, can you share the onChange() client script that you created but did not work.