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.

How to access specific field from current form in UI Macro?

Patrick Moura
Tera Guru

Hello folks,


I created a custom UI Macro to dynamically display images according to the return from my Script Include.


I have already tested the Script and it is correctly returning the URL of the image, my UI Macro is also successfully displaying the image when I define my "title" variable as a String with the name of any film.


The problem is that there is a field called "name" in the table, where I can see it in the Form, but I cannot access it within my Macro UI in any way.

 

I have already tried the following codes:

 

 

 

<g:evaluate var="imageUrl" object="true">
   //Examples of attempts
    var title = current.name;
    var title = g_form.getValue("name");
    var title = jellyContext.getParameter('name');
    //title variable is not filled in any way, only manually

    var myScriptInclude = new OmdbUtils();
    imageUrl = myScriptInclude.getImageUrl(title);
</g:evaluate>

 

 

 

None worked (current, g_form, jellyContext).
Using GlideRecord didn't work either.

 

 

1 ACCEPTED SOLUTION
2 REPLIES 2

Patrick Moura
Tera Guru

Thanks @Anirudh Pathak, I resolved it using <script> instead of <g:evaluate>.