How to clear reference field value

keval3
Tera Contributor

Hi All,

in my custom table I want remove reference field value bases on change of choice. kindly let me know how to do it.

I have 2 fields 1 is choice called 

Purchasing Group on change of this field reference field called User list value should be clear.
 
Thanks & Regards
KP

 

4 REPLIES 4

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Sounds like UI Policy could do this easily. Whats your concern doing this?

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn

OlaN
Giga Sage
Giga Sage

Hi,

The easiest way of doing this, is to create a onChange Client script that triggers when the field changes, and clears the value of the other field with a script like below:

g_form.clearValue('your_reference_field_name_to_clear');

keval3
Tera Contributor

Hi,

below script wan't add anything from reference table

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

   //Type appropriate comment here, and begin script below

   g_form.clearValue('user_list');
}

Mark Roethof
Tera Patron
Tera Patron

Perhaps this helps:
- 2019-07-16 - Article - Clear the field value / Clear the variable value

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn