Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Pass values to jelly

malu
Tera Contributor

I need to pass the retrieved value from g:evaluate outside of it. Here in the below script i have inci.name from g:evaluate want to pass it to <td> tag .how can i do this?

<tr>

  <g:evaluate var="jvar_data" object="true">

  var inci = new GlideRecord('sc_cat_item');

  inci.get("${cbr.sys_id}");

  inci.name;

    gs.log("inci.name==>"+"${jvar_data}"); // It is empty

  gs.log("inci.name_cat"+inci.name); // I can get this data in log

    </g:evaluate>

                    <td>${jvar_data}</td>

1 ACCEPTED SOLUTION

ramireddy
Mega Guru

Just assign that property to any variable and you can access that variable in jelly script.




<tr>


  <g:evaluate var="jvar_data" object="true">


  var inci = new GlideRecord('sc_cat_item');


  inci.get("${cbr.sys_id}");


  var incidentname = inci.name;


    </g:evaluate>


                    <td>${incidentname}</td>



View solution in original post

4 REPLIES 4

Chuck Tomasi
Tera Patron

Hi Malu,



Try this


Change inci.name to inci.getValue('name') (to strip out the value and not get all the attached methods.)


Make the last statement in your g:evaluate block.


I wouldn't worry about object="true". You are not returning an object.



<g:evaluate var="jvar_data">


  var inci = new GlideRecord('sc_cat_item');


  inci.get("${cbr.sys_id}");


  inci.getValue('name');


    </g:evaluate>



                    <td>${jvar_data}</td>


ramireddy
Mega Guru

Just assign that property to any variable and you can access that variable in jelly script.




<tr>


  <g:evaluate var="jvar_data" object="true">


  var inci = new GlideRecord('sc_cat_item');


  inci.get("${cbr.sys_id}");


  var incidentname = inci.name;


    </g:evaluate>


                    <td>${incidentname}</td>



malu
Tera Contributor

I got this worked on changing the code as below



<tr>


                      <g:evaluate var="jvar_data">


                        var conf= new GlideRecord('sc_cat_item');


                          conf.get("${cbr.sys_id}");


                        conf.name;


                      </g:evaluate>


                              <td>${jvar_data}</td>



Thanks Everyone


Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Hi,



you dont have to make it so difficult.



Take a look at this example:



This gets a incident record inside the evalute, then I can use that object outside of the evaluate



<?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 grtest = new GlideRecord('incident');


grtest.get('1e03cf840f7312004cf365ba32050eaa');



</g:evaluate>



  <h1> ${grtest.short_description}</h1>


</j:jelly>




//Göran