- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2025 12:31 PM
On the KBA edit page, I have a UI action with the following:
function openAttestationWindow() {
var dialog = new GlideDialogWindow("attestation_window");
dialog.setWidth(400);
dialog.setTitle("Article Attestation");
dialog.setPreference("sysparm_sys_id", g_form.getUniqueValue()); // Pass sysparm_sys_id correctly
dialog.setPreference("resizable", true);
dialog.render();
}
This correctly opens my UI page where I have script that prints some HTML, but none of the control code seems to work. Even something as simple as this:
<g:evaluate var="kbSysId" expression="sysparm_sys_id ? sysparm_sys_id : 'No sys_id found'"/>
<g:out var="kbSysId"/>
This should print SOMETHING, but prints nothing. I have it sandwiched between text so I know that the text is working, but the jelly code is just ignored. Same for this:
<g:evaluate var="articleOwnerStatus" expression="current.article_owner ? 'Complete' : 'Incomplete'"/>
<li style="color: ${articleOwnerStatus == 'Complete' ? 'green' : 'orange'};">${articleOwnerStatus == 'Complete' ? '✔' : '✘'} Has an Article Owner (Dept) value</li>
I get the LI bullet with text, but no color and no check/x. What is going on?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2025 03:46 PM
Apparently g:out does not work for unknown reasons, but I was able to finally get this working using the following:
<g:evaluate var="kbRecord" jelly="true" object="true">
var kbRecordGr = new GlideRecord("kb_knowledge");
kbRecordGr.get(RP.getParameterValue("sysparm_sys_id"));
kbRecordGr;
</g:evaluate>
${kbRecordGr.short_description}<br/>
${kbRecordGr.cmdb_ci.name}<br/>
${kbRecordGr.u_article_owner.name}<br/>
<j:if test="${kbRecordGr.flagged}">
<p>flagged</p>
</j:if>
<j:if test="${!kbRecordGr.flagged}">
<p>Noteflagged</p>
</j:if>
The first thing is that I needed to do a direct glide lookup with the sys_id passed from before. Then I can just check the values, but for NO REASON, I have to use the kbRecordGr value from the evaluate and not kbRecord itself. It's incredibly weird, but it finally works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2025 12:38 PM - edited 05-30-2025 12:40 PM
Hi Jeremy,
Please find the code below:
<!-- Correct variable evaluation and output -->
<g:evaluate var="kbSysId" expression="sysparm_sys_id ? sysparm_sys_id : 'No sys_id found'"/>
<g:out var="kbSysId"/> <!-- This will display the sys_id -->
<!-- Proper Jelly conditional syntax for styling -->
<li>
<g:choose>
<g:when test="${articleOwnerStatus == 'Complete'}">
<span style="color: green;">✔</span>
</g:when>
<g:otherwise>
<span style="color: orange;">✘</span>
</g:otherwise>
</g:choose>
Has an Article Owner (Dept) value
</li>
Key Fixes:
Replaced JavaScript-style ternary operators (? with proper Jelly <g:choose> tags
Ensured proper use of <g:out> to display evaluated variables
Please mark this as helpful and correct if this solves your issue.
Thanks,
Yaswanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2025 01:07 PM
I revised my code to the following (in its entirety) to test this:
<?xml version="1.0" encoding="utf-8"?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<div>
<!-- Correct variable evaluation and output -->
<g:evaluate var="kbSysId" expression="sysparm_sys_id ? sysparm_sys_id : 'No sys_id found'"/>
<g:out var="kbSysId"/> <!-- This will display the sys_id -->
<!-- Proper Jelly conditional syntax for styling -->
<li>
<g:choose>
<g:when test="${articleOwnerStatus == 'Complete'}">
<span style="color: green;">✔</span>
</g:when>
<g:otherwise>
<span style="color: orange;">✘</span>
</g:otherwise>
</g:choose>
Has an Article Owner (Dept) value
</li>
</div>
</j:jelly>
* kbSysId does not print
* The text "Has an Article Owner (Dept) value" prints, but has no color nor X/Check
To be safe, I erased all client and processing script as well leaving only the above. It doesn't respond.
My process again is that I find a KB article. I click Edit. In the Edit screen (not checked out), there's a button. Pressing that button runs the code to open the UI Page in a pop up window. That window has the above code. The code does not work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2025 01:19 PM
Try this code:
<?xml version="1.0" encoding="utf-8"?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide">
<div>
<ul>
<!-- Test output -->
<li><g:out>Test: Jelly is working</g:out></li>
<!-- sys_id display -->
<li>
<g:evaluate var="kbSysId" expression="sysparm_sys_id ? sysparm_sys_id : 'No sys_id found'"/>
<g:out var="kbSysId"/>
</li>
<!-- Article owner status -->
<li>
<g:choose>
<g:when test="${current.article_owner}">
<span style="color: green;">✔</span>
</g:when>
<g:otherwise>
<span style="color: orange;">✘</span>
</g:otherwise>
</g:choose>
Has an Article Owner (Dept) value
</li>
</ul>
</div>
</j:jelly>
- In your client script, ensure you're passing the correct sys_id:
dialog.setPreference("sysparm_sys_id", g_form.getUniqueValue());
If the "Test: Jelly is working" message appears, the problem might be with logic.
Mark this as helpful and correct if this issue is resolved.
Thanks,
Yaswanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2025 02:38 PM
The UI Action (button) has this code:
function openAttestationWindow() {
var dialog = new GlideDialogWindow("attestation_window");
dialog.setWidth(400);
dialog.setTitle("");
dialog.setPreference("sysparm_sys_id", g_form.getUniqueValue()); // Pass sysparm_sys_id correctly
dialog.setPreference("resizable", true);
dialog.render();
}
I copied your jelly code entirely and pasted into the "attestation window" UI page without any other script or code of any kind. The result was this: