<script custom-tag="" type="application/ld+json">{"@context":"https://schema.org","@type":"TechArticle","headline":"Custom UI: Reference macro doesn't bubble change event when handler defined on g:ui_reference tag","image":"http://support.servicenow.com/29f1d2661baf6010cafa53d8624bcb43.iix","author":{"name":"ServiceNow Support","url":"http://support.servicenow.com/now"},"keywords":"ServiceNow, NowSupport public Knowledge Base articles, Known Error,KB0863528,","wordcount":"190","publisher":"ServiceNow","url":"https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0863528","datePublished":"2020-11-04","dateCreated":"2020-11-03","dateModified":"2023-11-21","description":"<h2>Custom UI: Reference macro doesn't bubble change event when handler defined on g:ui_reference tag</h2><br/><div style=\"overflow-x:auto\"><h2>Description</h2><div><p>When adding an onchange attribut","articleBody":"<h2>Custom UI: Reference macro doesn't bubble change event when handler defined on g:ui_reference tag</h2><br/><div style=\"overflow-x:auto\"><h2>Description</h2><div><p>When adding an onchange attribute to a reference macro (using the g:ui_reference), the onchange listener is not triggered when the value of the reference macro is set via an ATF step Set Component Values (Custom UI) or via the Page Inspector.</p></div><h2>Steps to Reproduce</h2><div> <p></p><p>1. Create a sys_ui_page with the following content:<br /><?xml version="1.0" encoding="utf-8" ?><br /><j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null"><br /><g:ui_reference name="usrrequestor" query="active=true" id="usrrequestor" table="sys_user" value="" onchange="console.log('### OnChange Fired');"/><br /></j:jelly><br /><br />2. Open the ui page and open the ATF Page Crawler<br />3. Select the element and set its value to any value<br />4. Look at the console<br /><br />Behavior: Console logs do not contain "### OnChange Fired"<br />Expected: Console logs should contain that log statement</p></div><h2>Workaround</h2><div><p>A change event is fired from a different, not-instrumented, element of the reference macro's expansion. This change event bubbles and can be caught via an element which holds the reference macro (such as a div). When manually setting the reference macro's value, this event is fired when clicking away from the reference macro after setting its value.</p></div><div><br /><strong>Related Problem: PRB1442253</strong></div></div>"}</script>