How to dynamically show field message for an Aux table field displayed on main form?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi All,
I am working on a requirement on a custom ServiceNow form.
We have two related tables:
- ESG Task Enhance — main table/form
- ESG Task Enhance Aux — related Aux table
The field “Can you recommend someone else for this role?” is stored on the ESG Task Enhance Aux table, but it is displayed and used on the main ESG Task Enhance form through the Aux reference.
Requirement:
- If ESG Task Type = ESG Participant Acceptance, the message should not be visible.
- If ESG Task Type = ESG Participant Identification and Can you recommend someone else for this role? = No, then a message should appear under that field.
- If the value is Yes, the message should not appear.
I tried using an onLoad Client Script with g_form.showFieldMsg(), and it works correctly after the form is saved:
However, the challenge is with the dynamic onChange behavior.
Since the field belongs to the Aux table, I cannot directly select u_other_recommend as the field in an onChange Client Script on the main ESG Task Enhance table. The main table only shows the Aux reference field.
I also tried creating the onChange Client Script on the ESG Task Enhance Aux table, but it does not trigger when the field is changed from the main ESG Task Enhance form.
I also explored controlling the existing Form Annotation using DOM manipulation, but DOM access is restricted in this client script context with the error:
document is not accessible in this client script
So my questions are:
- Is there a supported way to trigger onChange behavior for an Aux table field displayed on the main form?
- Can g_form.showFieldMsg() be dynamically controlled for a related/Aux table field on the main form without saving/reloading?
- Would a UI Policy, UI Policy Script, GlideAjax, or another approach be recommended for this scenario?
- If immediate dynamic behavior is not possible, is onLoad with g_form.showFieldMsg() the best supported approach?
Any suggestions or best practices would be helpful.
Thanks!