Can you use \${jvar_var} inside an evaluate?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2016 09:58 AM
I am trying to add a new column to the shopping cart order screen. I created a new field, closely related to the Short Description field, that I want to be displayed on the Order Confirmation page.
Below is the script I'm trying to use. When I comment out the sys_id query line on ${jvar_sc_req_item.. the script actually works and outputs my "Test column" on the order screen. When I leave that line it, it breaks and it doesn't output anything. Something is wrong with that line. Am I unable to use a jvar variable this way in an evaluate tag? Any suggestions on what I need to do to get this to work?
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g2:evaluate var="jvar_page" jelly="true">
var page = "";
var pageTitle = "";
var pageGR = new GlideRecord("sc_req_item");
pageGR.addQuery("sys_id", ${jvar_sc_req_item.getID());
pageGR.query();
if (pageGR.next()) {
page = pageGR.cat_item.u_confirmation_screen_text;
}
page;
</g2:evaluate>
<tr>
<td colspan="3">
Test column
</td>
</tr>
<tr>
<td colspan="3" style="padding: 4px;">
${jvar_page}
</td>
</tr>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2016 11:26 AM
The line pageGR.addQuery("sys_id", ${jvar_sc_req_item.getID()); is missing the closing curly brace → }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2016 03:45 PM
Hi Aaron,
I'm on Fuji P12. I'm able to easily create the new column heading with a new column macro. Now I want to display the short description from the request item, not the cat_item, in the column for each request item listed. Have you had luck doing this? Above I see you're still pulling from the cat_item but I believe I can use the same method to put from the request item. What do you think?
Thanks,
Jon

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2016 10:56 AM
Hi Aaron,
You can access Jelly vars within your <g:evaluate..> blocks by including jelly="true", however you need to refer to it in the following fashion:
pageGR.addQuery("sys_id", jelly.jvar_sc_req_item);
I'm not certain if you'll need to include ".sys_id" or ".toString()" to get the ID out for your query, but prefixing with "jelly." is how you would reference the jelly variable itself.
Please see the wiki example 7.2 here: Extensions to Jelly Syntax - ServiceNow Wiki
Thanks,
-Brian