Clarity PPM

Expand all | Collapse all

How to work with Gel script?

  • 1.  How to work with Gel script?

    Posted 08-20-2018 12:56 AM

    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, 

     



  • 2.  Re: How to work with Gel script?

    Posted 08-20-2018 01:35 AM

    Could you please post the error, you received when the above script was run ?

     

    Regards,

    Samik



  • 3.  Re: How to work with Gel script?

    Posted 08-20-2018 11:38 AM

    Hello Samik, 

    Thanks you very much, the message is:

     

     

    Regards, 

    Saulo



  • 4.  Re: How to work with Gel script?

    Posted 08-20-2018 11:53 PM

    When you say "custom object 'pac_beneficiaries' linked to 'inv'", can you please expand on this.  Is pac_beneficiaries a sub-object of Project.  I'm assuming yes as your XOG has odf_parent_id which you are setting from inv_investments.code.

     

    I have never taken this approach and used:

    parentInstanceCode="XXXXX" parentObjectCode="project"  (where XXXXX is the Project Code)

    in the 'instance' tag.

     

    Please set-up sample data in your non-prod environment, and XOG out the data, which will then show you the format of the XOG file you should be replicating for your GEL scripts.



  • 5.  Re: How to work with Gel script?

    Posted 08-21-2018 12:15 AM

    Hi 

     

    You need to login xog and get a session id before you execute xog in Gel script like as below.

    Your Gel script seems not to log into xog.

     

    <gel:parameter default="http://nikuvm:80" var="XOGURL"/>
    <gel:parameter default="svong" var="XOGUsername"/>
    <gel:parameter default="svong" secure="true" var="XOGPassword"/>

    <!-- Log into XOG and get a session ID -->
    <soap:invoke endpoint="${XOGURL}/niku/xog" var="auth">
    <soap:message>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xog="http://www.niku.com/xog">
    <soapenv:Header/>
    <soapenv:Body>
    <xog:Login>
    <xog:Username>${XOGUsername}</xog:Username>
    <xog:Password>${XOGPassword}</xog:Password>
    </xog:Login>
    </soapenv:Body>
    </soapenv:Envelope>
    </soap:message>
    </soap:invoke>

     

    There is sample code in manual. I hope it is useful for you.

    GEL Examples: Running the XOG

     

    Regards,

    Shoichi