Client script to open reference field dialog on load

ycd
Tera Contributor

I had another open question related to a similar topic, but it seems I should have provided more context.

I'm currently working on a custom app, and when a custom form loads, I'm aiming to display the dialogue that corresponds to one of the reference fields on that form.

This is primarily intended to enhance the user experience. I am aware that users can click on the small search icon, but due to the specific form factor of the rendering on certain devices, we are seeking an alternative solution.

 

Just as an example, consider the Incident form: upon loading the form, say our goal is for the associated dialogue linked to the 'assigned_to' field to automatically open.

 

I'm just inquiring whether achieving this is possible through client-side scripting or any other means.

4 REPLIES 4

Hemanth M1
Giga Sage
Giga Sage

Hi @ycd , 

 

Why don't we simply use below line in on load client script

 

g_form.showFieldMsg('assigned_to','your message');

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

ChrisBurks
Giga Sage

Hello @ycd,

Although it can be done in a client script, it may not be worth as it would require using DOM manipulation on an out-of-box created element. This is bad because ServiceNow could change the attributes of that element in any updated release which would break it.

If you would like to apply a UI such as when showing a form with fields pertaining to a record such as the reference icon "i" on a reference field, then a reference decoration could be used and within its script it could be triggered on load. With a custom UI decoration you can define your own element and then DOM manipulation (to an extent) is acceptable because ServiceNow shouldn't touch your custom element. Or if you are not using this for Agent Workspace a UI formatter could be used too.