- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 04:23 AM
Hi all,
I have this jelly script below where we queried a table and displays all records. It is working so and fine.
I want to add the option to display "No record found" in case the query is empty.
I tried to add an if but does not work.
Can anyone help me with this script by adding the lines that will check if the query is empty and set a message to be displayed.
This is a ui page.I have a icon on HR case which onclick called the UI macro which will render the result on an Iframe.
//Script below
<?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="jvar_opened_for" expression="RP.getWindowProperties().get('opened_for')" />
<g:evaluate var="jvar_employee_language" expression="
var sys_user = new GlideRecord('sys_user');
sys_user.get(RP.getWindowProperties().get('opened_for'));
sys_user.u_employee_language;
" />
<div id="internal_messages_list">
<ol>
<g2:evaluate var="jvar_item" expression="
gr = new GlideRecord('u_internal_message');
gr.addQuery('u_user',RP.getWindowProperties().get('opened_for'));
gr.addQuery('u_start_date', '<=', gs.daysAgo(0));
/*gr.addQuery('u_expiration_date', '>=', gs.daysAgo(0));*/
gr.query();
" />
<j2:while test="$[gr.next()]">
<li><p><g2:no_escape>$[NS:gr.u_message]</g2:no_escape></p></li>
</j2:while>
</ol>
</div>
</j:jelly>
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 06:24 AM
On the line before your while loop you could do this:
<j2:if test="$[!gr.hasNext()]">
No records
</j2:if>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 04:53 AM
Try this before your j2:while.
<j2:if test="gr.getRowCount() == 0" >
No records found<br />
</j2:if>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 05:55 AM
Nope. not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2016 04:57 AM
Sorry about that. I forgot my $[ and ] to make that actually work.
Thanks for picking up the slack Brad!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2024 11:18 AM
Hi @Chuck Tomasi , @Brad Tilton ,
I need your help very urgent....I have below script which always satisfying if condition or may be not working even though users dont have appropriate roles while showing the buttons on UI Macro which is used in workplace portal widget . Below is my code in ui macro.
Please suggest.
Thanks in Advance,