Set reference field value in UI page and show i icon aside of it.

Abhijit4
Mega Sage

Hello Everyone,

I have reference field in UI page where I am setting the value as below,

<g:ui_reference name="module" id="module" table="u_nowmodule"/>

gel('module').value='7cf7a0861be55c50191adc6a9b4bcb1d';
gel('sys_display.module').value='Incident Management';

this sets the value fine but it is not showing i icon beside it. Please refer below image,

Any help would be appreciated.

Thanks.

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

1 ACCEPTED SOLUTION

Hi Rich,

can you try to add this 1 line after your existing and it should work fine.

gel('module').value='7cf7a0861be55c50191adc6a9b4bcb1d';
gel('sys_display.module').value='Incident Management';

gel('moduleLINKreplace').style.display = "";

Regards
Ankur

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

View solution in original post

6 REPLIES 6

Nice

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

alandalf
Tera Contributor

I think I've found a better way to do this. The script which verifies the new reference field value is on an onChange event handler, which isn't triggered when the value is updated programatically. 

 

Running this script (to manually dispatch the event) after the value change makes it work much better for me.

 

document.getElementById('module').dispatchEvent(new Event('change'));