How to set a variable value in jelly script and pass its value to javascript?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2016 04:55 AM
Hi All,
I have this code with me:
<g:evaluate>
var tab = new GlideRecord('u_cms_menu_table');
tab.query();
</g:evaluate>
<j:while test="${tab.next()}">
<j:if test="${tab.hasNext() == true}">
<j:while test="${tab.next()}">
${j:set var="jvar_link" value="${tab.u_url.getDisplayValue()}"/>
</j:while>
</j:if>
</j:while>
It is taking a columns value from a table which I have created now i want to store it in a variable and pass it to a JavaScript function. The column has URLs to different pages i intend to get th URL under Navigation menu.
Thanks in advance.
Shipra Shaw
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2016 05:59 AM
If you're just pulling one field from each record, why not just throw them into an array and store it in a jelly variable?
<g:evaluate var="jvar_urls" object="true">
var urlArr = [];
var tab = new GlideRecord('u_cms_menu_table');
tab.query();
while (tab.next())
urlArr.push(tab.u_url.getDisplayValue());
urlArr;
</g:evaluate>
Now, you can pass your array into a client-side function with the syntax: ${jvar_urls} You can then process the array in your JavaScript function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2016 02:35 AM
Could you please explain what is the significance of var="jvar_urls" in the code you have provided. I dont need an array i just need to save one record and i want to use that record in another addQuery.
Thanks,
Shipra Shaw

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2016 04:09 AM
jvar_urls is the name of the variable that will be set to the result of the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2016 04:30 AM
Hi Mujtaba, I dont need to pass it onto a script i just need to save it and use in an addQuery function. How to do that? Kindly help!! Thanks, Shipra Shaw