Jelly <j:if> condition issue

xiaix
Tera Guru

Trying to create a Jelly if condition that will essentially do this:

if ((jvar_calling_UI_Page == 'bcp_DEPT_Author_EDIT') || (jvar_calling_UI_Page == 'bcp_DEPT_FULL_VIEW' && bcpPROCESSES.u_name != ''))

I've come up with this:

<j:if test="(${jvar_calling_UI_Page == 'bcp_DEPT_Author_EDIT'}) || (${jvar_calling_UI_Page == 'bcp_DEPT_FULL_VIEW'} ${AMP}${AMP} ${bcpPROCESSES.u_name != ''})">

But it's not working.

I'm sure I just haven't had enough coffee this morning.   Could I get a little assistance with the correct way to form the jelly <j:if> syntax?

1 ACCEPTED SOLUTION

So I was correct.   This works:


find_real_file.png



Here's a good tip that I bet very few have ever encountered:



You cannot mix a <j:if> test condition with a jvar variable and a glide record field result


View solution in original post

10 REPLIES 10

Dennis R
Tera Guru

I'm not as familiar with Jelly as I'd like, but I think you need either $[AMP]$[AMP] (with brackets, not braces), or better yet, ${AND}, as your operator.


http://wiki.servicenow.com/index.php?title=Extensions_to_Jelly_Syntax#Ampersand



Hope this helps,


--Dennis R


Your link led me to this:   Extensions to Jelly Syntax - ServiceNow Wiki :



find_real_file.png



So:


<j:if test="${jvar_calling_UI_Page == 'bcp_DEPT_Author_EDIT' || (jvar_calling_UI_Page == 'bcp_DEPT_FULL_VIEW' &amp;&amp; bcpPROCESSES.u_name != '')}">



works, but it's always evaluating to true... so now onto why it's doing that.


Can you try using [] instead of {}


-Anurag

This is failing:


<j:if test="${jvar_calling_UI_Page == 'bcp_DEPT_FULL_VIEW' &amp;&amp; bcpPROCESSES.u_name != ''}">



This is failing:


<j:if test="$[jvar_calling_UI_Page == 'bcp_DEPT_FULL_VIEW' &amp;&amp; bcpPROCESSES.u_name != '']">



Anytime I try and use &amp;&amp; it pukes.