Line Separator in gel script
search cancel

Line Separator in gel script

book

Article ID: 265928

calendar_today

Updated On:

Products

Clarity PPM SaaS

Issue/Introduction

This is with reference to the line separator being used when we generate a file through gel scripting using the <file:writeFile> tag.

What is the default Line separator being used by Clarity and if there is any way to change it from the settings or by adding a parameter to the <file:writeFile> tag.

 

Resolution

To write a new line or append to the file as a new line, you can use the <file:line> tag, for example:

 

<!-- To write a new line or append to the file as a new line, you can use the <file:line> tag, for example: -->

 <file:line> <file:column value="Second line in file"/></file:line>
 <file:line> <file:column value="Third line in file"/></file:line>
 
<!-- Here is a full example: -->
<gel:script xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:core="jelly:core"
    xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
    xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:sql="jelly:sql"
    xmlns:xog="http://www.niku.com/xog"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:ftp="jelly:com.niku.union.gel.FTPTagLibrary"
 xmlns:file="jelly:com.niku.union.gel.FileTagLibrary">
 
<!-- QUERY FOR MULTIPLE RESULTS -->
<sql:query escapeText="0" var="multipleResults">
 <![CDATA[
SELECT FULL_NAME, UNIQUE_NAME, EMAIL
FROM SRM_RESOURCES
]]>
</sql:query>
 
 
 
<file:writeFile delimiter="," embedded="false" fileName="/opt/clarity/FILE.csv">
 <!-- REMOVE FIRST SECTION IF YOU DON'T WANT HEADERS -->
 <file:line>
 <file:column value="Full Name"/>
 </file:line>
 <core:forEach items="${multipleResults.rowsByIndex}" var="row">
 <file:line> <file:column value="Second line in file"/></file:line>
 <file:line> <file:column value="Third line in file"/></file:line>
 <file:line>
 <file:column value="${row[0]}"/>
 <file:column value="${row[1]}"/> 
 <file:column value="${row[2]}"/>
 </file:line>
 </core:forEach>
</file:writeFile>
 
</gel:script>