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.

Get variable value outside script tag in Ui MACRO

Bharath Reddy M
Tera Contributor

Hi,

I have a UI macro, purpose is that I need to show the retrieved data in a tabular format. For this inside the script tag I have a function which is fetching the sys_id using g_form,  Outside the script tag i'm using the g:evaluate to glide on a table with the sysid which i got through the function.. Inside the g_evaluate i'm getting the response and parsing it . The output is JSON array

 

As I need to glide how can I get that sys_id out from the script tag.

 

Thanks

1 REPLY 1

Joni V B
Tera Guru

Hi,

Inside the UI macro you can access "current" inside a <g2:evaluate> tag.

When you store that in a variable you can use it in different places in your macro.

 

<g2:evaluate>
    var recordID = current.getUniqueValue();
</g2:evaluate>

<div>I am currently looking at record with sys_id $[HTML:recordID]</div>