AnsweredAssumed Answered

How to work with Gel script?

Question asked by Saulex on Aug 20, 2018
Latest reply on Aug 21, 2018 by Shoichi_Sugawara

Hi guys!

I would like to know how to work with Gel script, since I am new to these issues and I have the following query: I have created a custom object 'pac_beneficiaries' linked to 'inv'. I have been asked to automatically generate details in the projects in this sub object, with which I have tried to create a script that starts automatically through an action. However, this error comes up when I run it and I wanted to know if you can help me by telling me if there is a syntax error: 

 

<gel:script 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">
<gel:setDataSource dbId="niku" var="nikuDS"/>
<core:catch var="erro">
<sql:query dataSource="${nikuDS}" escapeText="false" var="rs_cc">
<![CDATA[
select
inv_prj.code prj_code,
odf_prj.partition_code,
to_char(systimestamp, 'sssss.ff') new_id
from
inv_investments inv_prj
join odf_ca_project odf_prj on odf_prj.id = inv_prj.id
where
inv_prj.id = ?
AND inv_prj.is_active = 1
]]>
<sql:param value="${gel_objectInstanceId}"/>
</sql:query>
<core:if test="${rs_cc.getRowCount() &gt; 0}">
<core:set value="${rs_cc.rows[0]}" var="distri"/>
<gel:parameter default="" var="xog_user" />
<core:new className="com.niku.union.security.DefaultSecurityIdentifier" var="secId1"/>
<core:invokeStatic className="com.niku.union.security.UserSessionControllerFactory" method="getInstance" var="UserSessionCtrl"/>
<core:invoke method="init" on="${UserSessionCtrl}" var="secId3">
<core:arg type="java.lang.String" value="${xog_user}"/>
<core:arg type="com.niku.union.security.DefaultSecurityIdentifier" value="${secId1}"/>
</core:invoke>
<core:set value="${secId3.getSessionId()}" var="sessionID"/>
<gel:parse var="xog">
<NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_customObjectInstance.xsd">
<Header action="write" externalSource="NIKU" objectType="customObjectInstance" version="8.0"/>
<customObjectInstances objectCode="odf_ca_pac_beneficiarios">
<instance instanceCode="inv" objectCode="odf_ca_pac_beneficiarios">
<CustomInformation>
<ColumnValue name="code">BENEF1${distri.prj_code}</ColumnValue>
<ColumnValue name="name">BENEF1${distri.prj_code}</ColumnValue>
<ColumnValue name="com_idea_ca">pps</ColumnValue>
<ColumnValue name="por_emp_idea_ca">1</ColumnValue>
<ColumnValue name="pac_beneficiario">5002082</ColumnValue>
<ColumnValue name="pac_dist_costo">0.7</ColumnValue>
<ColumnValue name="partition_code">${distri.partition_code}</ColumnValue>
<ColumnValue name="odf_parent_id">${distri.prj_code}</ColumnValue>
</CustomInformation>
</instance>
<instance instanceCode="inv" objectCode="odf_ca_pac_beneficiarios">
<CustomInformation>
<ColumnValue name="code">BENEF2${distri.prj_code}</ColumnValue>
<ColumnValue name="name">BENEF2${distri.prj_code}</ColumnValue>
<ColumnValue name="com_idea_ca">pps</ColumnValue>
<ColumnValue name="por_emp_idea_ca">1</ColumnValue>
<ColumnValue name="pac_beneficiario">5002078</ColumnValue>
<ColumnValue name="pac_dist_costo">0.3</ColumnValue>
<ColumnValue name="partition_code">${distri.partition_code}</ColumnValue>
<ColumnValue name="odf_parent_id">${distri.prj_code}</ColumnValue>
</CustomInformation>
</instance>
</customObjectInstances>
</NikuDataBus>
</gel:parse>
<soap:invoke endpoint="internal" var="result">
<soap:message>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">
<soapenv:Header>
<xog:Auth>
<xog:SessionID>${sessionID}</xog:SessionID>
</xog:Auth>
</soapenv:Header>
<soapenv:Body>
<gel:include select="$xog"/>
</soapenv:Body>
</soapenv:Envelope>
</soap:message>
</soap:invoke>
<gel:set asString="true" select="$result/soapenv:Envelope/soapenv:Body/XOGOutput/Status/@state" var="xog_status_state"/>
<gel:set asString="true" select="$result/soapenv:Envelope/soapenv:Body/XOGOutput/Statistics/@failureRecords" var="xog_failure_records"/>
<core:if test="${(xog_status_state == 'FAILURE') || (xog_failure_records &gt; 0)}">
<gel:log level="debug">[CAS] XOG que fue ejecutado.</gel:log>
<gel:log level="debug">
<gel:expr select="$xog"/>
</gel:log>
<gel:log level="debug">[CAS] Resultado del XOG fue ejecutado.</gel:log>
<gel:log level="debug">
<gel:expr select="$result"/>
</gel:log>
<gel:log level="error">[CAS] Error al ejecutar el script.</gel:log>
</core:if>
<soap:invoke endpoint="internal" var="logout_session">
<soap:message>
<soapenv:Envelope>
<soapenv:Header>
<xog:Auth>
<xog:SessionID>${sessionID}</xog:SessionID>
</xog:Auth>
</soapenv:Header>
<soapenv:Body>
<xog:Logout/>
</soapenv:Body>
</soapenv:Envelope>
</soap:message>
</soap:invoke>
</core:if>
</core:catch>
<core:if test="${erro != null}">
<gel:log level="error">Error durante la ejecución del script: ${erro}</gel:log>
</core:if>
</gel:script>

 

Regards, 

 

Outcomes