How to clear value of g:ui_reference box in UI Page when user select different option?

bbf3562
Kilo Guru

There are 2 dropdown options for admin to select. If the admin select option #2 and type something in reference field search box but changed mind and select option #1, the ui reference field will change but the previous ui reference field still have remaining input value that need to be cleared. If click Option #2 again, it will switch back to first reference field but the old value that admin typed is still there. I have tried use gel('test').value = ""; but it isn't working. Anyone know why?

Here are my sample code,

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Try:


document.getElementById('sys_display.test').value = '';


document.getElementById('test').value = '';


View solution in original post

7 REPLIES 7

Try:


document.getElementById('sys_display.test').value = '';


document.getElementById('test').value = '';


That worked! Thank you!


This, plus this bit from another SN Community post[1] worked for me:

document.getElementById("company-referenceLINKreplace").style.display = "none";

Credit here goes to @Kieran Anson 

[1] https://community.servicenow.com/community?id=community_question&sys_id=713a774adb21ec50fa192183ca9619cd