Why I just can not get the field value from UI Macro

James100
Kilo Expert

Hi,

I have a field ('name') and a UI Macro on a form.

The UI Macro is just to get the field value and display it. The code is like below.

-----------------

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
        
     <g:evaluate var="jvar_user" object="true">
        ${ref_parent}.getValue("name");
    </g:evaluate>
    
    <div>name=${jvar_user}</div>

</j>

-----------------

Below is the page I'm getting. saying there is a reference error. I'm not familiar with Jelly and have no idea what's wrong. Can you help me out?

find_real_file.png

1 ACCEPTED SOLUTION

Hi James,

below worked for me in my instance; you need to use <g2:evaluate> tag; phase 2 jelly tags

I believe using phase 1 jelly i.e. <g:evaluate> it doesn't get the value

<g2:evaluate var="jvar_user" object="true">
        var value = current.name;

        gs.info('Value is: ' + value);
        value;
    </g2:evaluate>
    
    <div>name=$[jvar_user]</div>

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

17 REPLIES 17

James100
Kilo Expert

I resolved the issue by using <g2> and $[jvar_user].

I don't know why <g> doesn't work.

Thanks all for your advise!!!

Hi James,

That is what was mentioned in my previous comment to use <g2:evaluate> tag

I am glad to hear your goal has been achieved.
Saying this, I will appreciate if you close this thread, as answered.
Have a great rest of the day

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi James,

The solution you mentioned was already provided in my previous comment.

So did you mark the proper comment/post as correct.

Regards
Ankur 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

Thank you for your help! I'd like to mark your comment as correct one, but I went thru all the comments and didn't find the one you mentioned to use <g2>. In order to let others know the correct solution of my issue, I just marked my own comment. 

Please tell me in which comment you mentioned <g2> and I'd love to mark again. Have a good day.

 

Hi James,

please find the below image

Thanks & Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader