Clarity

  • 1.  New line CDATA (Gel Script)

    Posted Oct 22, 2015 01:54 AM

    Hi All,

     

    I have custom gel script to select description (String) of project from oracle database and sent to user via email

    In the email content I use CDATA and html tag "Text Area" as below

     

    <textarea>

    ${v_cr_description}

    </textarea>

     

    The problem is when user use "Enter" in the description. It's not show new line in the email content.

     

    I try use REPLACE function as below when select description field.

    1.REPLACE(a.GS_CR_DESCRIPTION,chr(10),'<br>') AS GS_CR_DESCRIPTION

    2.REPLACE(a.GS_CR_DESCRIPTION,chr(10),'\n') AS GS_CR_DESCRIPTION

     

    but It's not work.

     

    Thanks,

    Peerawat K.



  • 2.  Re: New line CDATA (Gel Script)

    Posted Oct 22, 2015 03:50 AM

    <br> has worked in the past I believe, but earlier Clarity versions used &#xA; as well to break lines in GEL emails - see this thread ; RE: how to use newline while concating data in foreach

     

    Your problem could be that the chr(10) is not recognised in your 'description' though - so your 'replace' would just never work? Have you tried chr(13) as well?

    ( chr(10) is LF, chr(13) is CR )



  • 3.  Re: New line CDATA (Gel Script)

    Posted Oct 22, 2015 06:19 AM

    Thank for your reply David.

     

    My field that I select is Description (String)

    111111111111111111111

    tttttttttttttttttttttttttttttttttt

    5555555555555555555

     

    I try

    1.REPLACE(a.GS_CR_DESCRIPTION,chr(13),'&lt;br&gt;') AS GS_CR_DESCRIPTION

    Result: 111111111111111111111<br> tttttttttttttttttttttttttttttttttt<br> 5555555555555555555

     

    2.REPLACE(a.GS_CR_DESCRIPTION,chr(13),'&#xA;') AS GS_CR_DESCRIPTION

    Result: 111111111111111111111 tttttttttttttttttttttttttttttttttt 5555555555555555555

     

    Still not work



  • 4.  Re: New line CDATA (Gel Script)

    Posted Oct 22, 2015 06:25 AM

    I'm not a html guy, but Google-ing suggests trying using the ASCII characters &#013; &#010;

     

    Ref : HTML Display line breaks within textarea - Stack Overflow



  • 5.  Re: New line CDATA (Gel Script)

    Posted Oct 22, 2015 12:50 PM

    Given that a textarea tag is an input tag, you should probably start by using something else.

     

    edit: meant to paste the following.

     

    Maybe try something like this:

    <div>${v_cr_description.replaceAll("(\r\n|\n)", "&lt;/br &gt;")}</div>
    


  • 6.  Re: New line CDATA (Gel Script)

    Posted Oct 28, 2015 11:18 PM

    Thanks for reply Andrew_Lerner

     

    I try as you guide, It's same result



  • 7.  Re: New line CDATA (Gel Script)
    Best Answer

    Posted Oct 29, 2015 03:44 AM

    Really? This sscce works for me:

     

    Set the emailRecipient parameter to your own email, the testProjectInternalId parameter to the internal id of a known project with that of a project with CR/LFs in its description.

     

    <gel:script xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:core="jelly:core"
        xmlns:file="jelly:com.niku.union.gel.FileTagLibrary"
        xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
        xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"
        xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:sql="jelly:sql" xmlns:xog="http://www.niku.com/xog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    
    
        <gel:parameter var="emailRecipient" />
        <gel:parameter var="testProjectInternalId" default="5000000" />
    
    
        <gel:setDataSource dbId="niku"/>
    
    
        <core:catch var="err">
        <sql:query var="rstProject">
        SELECT DESCRIPTION 
        FROM INV_INVESTMENTS II
        WHERE II.ID = ${testProjectInternalId}
        </sql:query>
    
    
        <core:set var="description" value="${rstProject.rows[0].get('DESCRIPTION')}" />
    
    
        </core:catch>
        <core:if test="${err != null}">
        ${err}
        </core:if>
        <core:set var="newDescription" value='${description.replaceAll("(\r\n|\n)", "&lt;/br &gt;")}' />
        <gel:log>${newDescription}</gel:log>
        <gel:email from="server@example.com" to="${emailRecipient}" subject="Project Carriage Return - Line Feed Test"><![CDATA[
            <html>
                <header></header>
                <body>
                    <div>${newDescription}</div>
                </body>
            </html>        
            !]]>
        </gel:email>    
    </gel:script>
    


  • 8.  Re: New line CDATA (Gel Script)

    Posted Oct 29, 2015 04:03 AM

    For the first I try replace in div tag. So I change replace before gel email tag.


    It's work, Thank you Andrew_Lerner.