Clarity

  • 1.  How to use And in test attribute of If tag in gel script

    Posted Jan 11, 2016 08:12 AM

    Hi All, I want to know how to implement multiple conditions( using AND , OR) in Core:if tag of Test attribute

     

    Thanks



  • 2.  Re: How to use And in test attribute of If tag in gel script
    Best Answer

    Posted Jan 11, 2016 09:09 AM

    Use ampersand && to use AND condition and double pipes || to use OR condition.

     

    <gel:script

         xmlns:core="jelly:core"

         xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary">

         <core:set var="color1" value="blue"/>

         <core:set var="color2" value="red"/>

         <core:if test="${color1 == 'blue' || color2 == 'notred'}">

              <gel:out>OR Condition works !</gel:out>

         </core:if>

         <core:if test="${color1 == 'blue' &amp;&amp; color2 == 'red'}">

              <gel:out>AND Condition works, too !</gel:out>

         </core:if>

     

    </gel:script>

     

    Output -

    OR Condition works !

    AND Condition works, too !



  • 3.  Re: How to use And in test attribute of If tag in gel script

    Posted Oct 17, 2017 07:44 AM

    HaseebR what version of Clarity are you using?

     

    In v14.2, any GEL core:if with an AND operator (escaped or not escaped) , produces the following error; even using your code.

     

    ERRORBPM-0703: Custom script syntax error at line 33, column 40: The entity name must immediately follow the '&' in the entity reference.

     

    Moreover after saving, in the Script textbox, the escaped &  is replaced by a non escaped &

     

     



  • 4.  Re: How to use And in test attribute of If tag in gel script

    Posted Oct 17, 2017 11:01 AM

    I just tried in v15.2 following AND conditions work fine:

    cond1  &#38;&#38; cond2

    cond1  &amp;amp; cond2

    However, previous conditions doesn't work in v14.2.0.237 011



  • 5.  Re: How to use And in test attribute of If tag in gel script

    Posted Oct 17, 2017 10:01 AM

    Why make things complicated when the reply is simple:

     

    <core:if test="${color1 == 'blue' and color2 == 'notred'}">

     

    should work as well



  • 6.  Re: How to use And in test attribute of If tag in gel script

    Posted Oct 17, 2017 11:22 AM

    thanks frean04

     

    You're right,  "and" works fine in all versions

    However, using caps (AND) it doesn't, after saving it gives some nice info.

     

    Caused by: org.apache.commons.jexl.parser.ParseException: Encountered "AND" at line 1, column 6.
    Was expecting one of:
        "||" ...
        "or" ...
        "&&" ...
        "and" ...
        ......

     

    I miss a good and complete GEL/jelly documentation....