Clarity PPM

Expand all | Collapse all

GEL: string with ampersand causes confusing behavior

  • 1.  GEL: string with ampersand causes confusing behavior

    Posted 10-12-2010 07:07 AM
    Within a GEL script, I want to retrieve a department name and use it as a sting later in the script. I retrieve the name which contains an ampersand, but when I use the tag, it converts the ampersand to &. Is there a way to set a variable that I can use later that doesn't convert the string? See below: 
          select d.shortdesc name from clarity.DEPARTMENTS d where d.id = 5000013  name = {xog_url_qry.rows[0].name}  ${xog_url_qry.rows[0].name}  
    name = ${DeptName}   The output looks likename = Prog Dist & Internationalname = Prog Dist & InternationalBPM-0546: Custom script has completed.      


  • 2.  Re: GEL: string with ampersand causes confusing behavior

    Posted 10-12-2010 07:07 AM
    Is this actually causing problems later on in your GEL script?    The & business is just the XML way of representing the special character & in the text (its not really "replacing" the text just making sure that the ampersand is not interpreted by the parser as a sepcial character)....    When I tried a quick example (using gel:out rather than gel:log) the final string comes out OK (with the & rather than the & construct)  Dave. Message Edited by Dave on 02-10-2009 09:01 AM [left]


  • 3.  Re: GEL: string with ampersand causes confusing behavior

    Posted 10-12-2010 07:07 AM
    Hi,  Even i have tried the same but I am getting & instead of & in  console.... Am I doing something wrong ?    ~Sonal  


  • 4.  Re: GEL: string with ampersand causes confusing behavior

    Posted 10-12-2010 07:07 AM
    Yes, it is causing me headaches. I condensed the gel script to the one above just to make sure the problem was in this statement.  I use the variable later and save  it to the database. I need the real string to be saved, not the one with '&'


  • 5.  Re: GEL: string with ampersand causes confusing behavior

    Posted 10-12-2010 07:07 AM
    Well (worst case), when you save back the string to the database you could just (oracle?) wrap it in a "replace"  i.e. in the SQL....  REPLACE ( my_variable_with_the_amp , '&' , '&' )  ?


  • 6.  Re: GEL: string with ampersand causes confusing behavior

    Posted 10-12-2010 07:07 AM
    Would Sam's tip on the util:replace help I wonder?  see:  http://caforums.ca.com/ca/board/message?board.id=CAClarityGeneralDiscussion&message.id=2139&query.id=74802#M2139<a href="http://caforums.ca.com/ca/board/message?board.id=CAClarityGeneralDiscussion&message.id=2139&query.id=74802#M2139"></a>  


  • 7.  Re: GEL: string with ampersand causes confusing behavior

    Posted 10-12-2010 07:07 AM
    I tried the suggestion of using  excapeText and that made no difference.  Gel doesn't accept the REPLACE function, unless I have the syntax wrong? Here is the code snipped within my script.                                                                      UPDATE CLARITY.ODF_CA_DEPARTMENT                                                                    SET hbo_parent_dept_name = REPLACE("${parentName}",'&amp;','&')                                                                    WHERE id = ${deptID}      Clarity won't even let me save the script. The error message  is “ Custom script syntax error at line 62, column 62: The entity name must immediately follow the '&' in the entity reference.â€?


  • 8.  Re: GEL: string with ampersand causes confusing behavior

    Posted 10-12-2010 07:07 AM
    I would guess here that as you inside sql at this point that the escape would not work - you would need to undertake this prior to the sql update - but Dave's workaround does the replace via sql afterwards so the same result is achieved.


  • 9.  Re: GEL: string with ampersand causes confusing behavior

    Posted 10-12-2010 07:07 AM
    The replace suggestion was close, but I finally found a syntax that worked!  Instead of               SET  department_name = REPLACE("${parentName}",'&amp;','&')         the statement that seems to work is              SET  department_name = REPLACE("${parentName}",'amp;','')       Thanks for all the suggestions!!   


  • 10.  Re: GEL: string with ampersand causes confusing behavior

    Posted 10-12-2010 07:07 AM
    ^ that IS lateral thinking, I like it!  BUT watch out, just in case your original data ever contains "amp;" as that would get messed up by this logic!  eg;   "I like to look at my penny black stamp; it makes me happy"   would turn into "I like to look at my penny black st it makes me happy"  (really contrived example I know!)   :-)


  • 11.  Re: GEL: string with ampersand causes confusing behavior

    Posted 11-13-2018 09:40 PM

    This is an OLD question, but I do have a solution for replacing '&amp;' with '&' in GEL strings.

     

    <core:set value="${tmp_string.replaceAll (&quot;\x26amp;&quot;,&quot;&amp;&quot;)}" var="tmp_string"/>