Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Trouble invoking UI Macro

Michael Domke
Tera Guru

I've created two new UI Macros based on two built-in UI Macros: "macro_watch_list" and "lightweight_glide_list". My new UI Macros are called "macro_monitor_list" and "lightweight_glide_list_2".

In the new "macro_monitor_list" UI Macro I defined the jvar_reference to a monitor table I'm using and I changed the UI Macro to invoke the new "lightweight_glide_list_2" UI Macro.



Seems pretty straight forward. But, the "macro_monitor_list" UI Macro doesn't show. If I change the "macro_monitor_list" to invoke the original "lightweight_glide_list" UI Macro, it displays just fine. I haven't changed anything in my copied "lightweight_glide_list_2" UI Macro (it's an identical copy) so I'm at a loss as to why it doesn't render?

Any thoughts?

5 REPLIES 5

Michael Domke
Tera Guru

To be honest, I'm surprised this issue did not get as much attention as I thought it would. I figured someone would have chimed in relatively quickly, especially from the ServiceNow crowd. Anyway, I happened upon a solution (work-around?), but as you'll see, there still seems to be an issue that ServiceNow probably needs to address or explain.

The Solution:
Rather than invoking the UI Macro using this format:


<g:lightweight_glide_list_2 />


Using the format with the macro= parameter renders the UI Macro as expected:


<g:some_arbitrary_name macro="lightweight_glide_list_2" />


So the question for ServiceNow is, why doesn't the first approach work?

Thanks,


My bad on the using the macro= above. The tag must be named macro_invoke and not some arbitrary name. For example:


<g:macro_invoke macro="lightweight_glide_list_2" />


Thank you for this fix!   I too am not sure why this needs to be done this way.


CapaJC
ServiceNow Employee
ServiceNow Employee

Sounds like a caching issue. Perhaps new UI Macros don't automatically update the list of templates/macros available when referenced using the g:u_macro_name tag.

I wonder if it would work as expected if you used the g:inline tag instead whenever you're calling a macro - I'll bet it uses a different cache, or maybe bypasses a cache:



<g:inline template="u_macro_name" />