Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to retrieve a value from a current record in Jelly script?

xuan
Giga Contributor

Hi all,

Basically, I need a UI macro to retrieve the value of a filed from the current record.

I tried the following jelly script, it returns null.

<g:evaluate var="jvar_test">
var val = ${ref}.test_field;
</g:evaluate>

I also tried this, it doesn't work.

<j:set var="jvar_test" value="${current.test_field}">

Can anyone help?

Thanks in advance.

Xuan

1 ACCEPTED SOLUTION

Try below



<g2:evaluate var='jvar_id'>

          var val = current.getValue('caller_id');


val;

</g2:evaluate>


$[jvar_id]   // will print the sysid of caller


View solution in original post

7 REPLIES 7

It's working.


Thanks so much!!!


Hello Ashish ,



I used the below code to get the value of caller from incident.



<?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 object="true" var="jvar_gr">


  var user_sys_id = current.getValue('caller_id');


  gs.log("userID:"+userID );


      var gr = new GlideRecord("sys_user");


  gr.addQuery('sys_id', user_sys_id);


        gr.query();


    gr;


</g:evaluate>




  <j:if test="${jvar_gr.next()}">


  <j:set var="jvar_phase2" value= "${gr.u_dsid} "/>


  </j:if>





<a href= 'xxxx://users/${jvar_phase2}' >click here</a>



</j:jelly>



But the   user_sysid is giving null . sometimes the code below this line won't be executed . Could you please suggest if   any change needs to be done?



Thanks ,


Adarsh S


Hi Brian,



It returns null.