Using "&&" in <g: evaluate>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2015 02:46 PM
I am creating a CMS site, i used a ui macro in which i am using a boolean variable in <g:evalute>. The issue is I am unable to use '&&' in the If condition. I tried using "<![CDATA[ ....]]" and also "&" but whenever i am trying to print this boolean variable outside< g:evaluate > it returns null.
Any help is appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2015 07:57 PM
You can replatec & by &
so your replaced code would be
&& == &&
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2015 08:41 PM
Hi Prateek, you should use ${AND} , but you could also use && in a Jelly test tag.
16 And
For the same reasons given for the ampersand, use ${AND} to insert a JavaScript and in Jelly. For example:
if (d ${AND} e) var color = d.value;
Alternately, in a Jelly test you would use &&. For example:
<j:if test="${jvar_form_name == 'sys_form_template' && !RP.isDialog()}">
source: http://wiki.servicenow.com/index.php?title=Extensions_to_Jelly_Syntax#And
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2015 02:51 PM
Thanks Deepak and Berny
I tried both of the option but none of it is working. I am using this to concatenate my multiple condition in if block. here is schema :
<g: evaluate>
boolean false;
if(var1=='abc' && var2=='xyz'&& var3=='fae' ...........)
{
boolean true;
}
</g:evaluate>
But both the option && or ${AND} Not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2015 04:46 PM
HI Prateek,
It works for me. Perhaps the problem may be that you don't have a space between 'xyz' and &.
Here goes the code which works for me:
<?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_now'>
var a = true;
var b = true;
if (a && b)
{
gs.nowNoTZ();
}
</g:evaluate>
This macro current Date is: <input id="id_test" value='${jvar_now}' />
</j:jelly>
The following is the result:
Thanks,
Berny