AnsweredAssumed Answered

Update custom field from Project Task

Question asked by Calemirou on Feb 21, 2017
Latest reply on Feb 22, 2017 by Dave_3.0

Hello Everyone,

I created a query that allows me to give a single line, it's the task that contains the field that i want to change (boolean = "true").
This is my Gel script with the XOG that i'm not sure if it's correct or not ...

 

 

<customScript languageCode="gel">

<scriptText>
<gel:script
xmlns:core="jelly:core"
xmlns:file="jelly:com.niku.union.gel.FileTagLibrary"
xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
xmlns:jxml="jelly:xml"
xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sql="jelly:sql"
xmlns:util="jelly:util"
xmlns:x="jelly:org.apache.commons.jelly.tags.xml.XMLTagLibrary"
xmlns:xog="http://www.niku.com/xog"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


<!-- ***********************************
PARAMETRES
************************************ -->

<!-- Params -->
<!-- BD CONNECTION ** -->
<gel:setDataSource dbId="Niku" />
<!-- -->
<core:set value="NA" var="hostClarity" />
<core:set value="clarity" var="loginClarity" />
<core:set value="passw2016" var="passClarity" />
<!-- connection parameter -->
<core:catch var="exception">
<sql:query var="req"><![CDATA[
Select
NVL ((SELECT X_ATT_VALUE
FROM ODF_CA_X_SO_TECH_CONF
WHERE X_ATT_ATTRIBUTE_ID = 'hostClarity'), 'NA') hostClarity
From Dual
]]></sql:query>
</core:catch>
<core:choose>
<core:when test="${exception != null}">
<gel:log category="SQL" level="ERROR" message="[-] SQL error : ${exception}" />
</core:when>
<core:otherwise>
<core:if test="${req.rowCount !=0}">
<core:forEach items="${req.rowsByIndex}" trim="true"
var="confRow">
<core:if test="${confRow[0] != null}">
<core:set value="${confRow[0]}" var="hostClarity" />
</core:if>
</core:forEach>
</core:if>
</core:otherwise>
</core:choose>
<core:choose>
<core:when test="${loginClarity.compareTo('NA') == 0}">
<gel:log category="HOST" level="ERROR"
message="[-] Connexion parameter ERROR (loginClarity not set)." />
</core:when>
<core:otherwise>
<gel:log category="HOST" level="info"
message="Xog user found: ${loginClarity}" />
</core:otherwise>
</core:choose>

<core:choose>
<core:when test="${passClarity.compareTo('NA') == 0}">
<gel:log category="HOST" level="ERROR"
message="[-] Connexion parameter ERROR (passClarity not set)." />
</core:when>
<core:otherwise>
<gel:log category="HOST" level="info"
message="Xog user password found: ${passClarity}" />
</core:otherwise>
</core:choose>

<!-- ** Connexion Clarity server ** -->
<gel:log category="XOG" level="info" message="[-] connecting to ${hostClarity}..."/>

<!--****************************************
LOGON XOG
****************************************-->
<soap:invoke endpoint="${hostClarity}/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>${loginClarity}</xog:Username>
<xog:Password>${passClarity}</xog:Password>
</xog:Login>
</soapenv:Body>
</soapenv:Envelope>
</soap:message>
</soap:invoke>

<gel:set asString="true" select="$auth/soapenv:Envelope/soapenv:Body/xog:SessionID/text()" var="sessionID"/>
<core:choose>
<core:when test="${SessionID == null}">
<gel:out>Log in impossible. Vérifiez le hostname/username/password.</gel:out>
<gel:log>Log in impossible. Vérifiez le hostname/username/password.</gel:log>
<core:set value="true" var="stepError"/>
</core:when>
<core:otherwise>
<gel:out>Login succeed. Session ID = ${SessionID}</gel:out>
<gel:log>Login succeed. Session ID = ${SessionID}</gel:log>
</core:otherwise>
</core:choose>

<!-- ** query ** -->
<sql:query var="data"><![CDATA[
select invp.id, name , prname, prIsMilestone,xtd_export_fsp
from odf_ca_task od inner join PRTASK pr on pr.prID = od.id
inner join inv_projects inv on inv.prid = pr.prprojectid
inner join inv_investments invp on inv.prid=invp.id
where od.id = '5872042'
]]>
</sql:query>


<gel:log category="QUERRY" level="info" message="${data.rowCount}" />

<core:set value="${data.rows[0].xtd_export_fsp}" var="xtd_export_fsp"/>
<core:set value="true" var="xtd_export_fsp"/>

<gel:log category="XOG" level="info"
message="Debut du parsing de la variable check" />

<gel:parse var="val_xml">
<NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_project.xsd">
<Header action="write" externalSource="NIKU" objectType="project" version="13.3.0.286"/>
<Projects>
<Project projectID="${data.rows.0.id}" name="${data.rows.0.name}">
<Tasks>
<Task name="${data.rows.0.prName}" taskID="${data.rows.0.prExternalID}">
<CustomInformation>
<ColumnValue name="xtd_export_fsp">${xtd_export_fsp}</ColumnValue>
</CustomInformation>

</Task>
</Tasks>
</Project>
</Projects>
</NikuDataBus>
</gel:parse>
<gel:log category="QUERRY" level="info" message="${data.rows.0.xtd_export_fsp}" />
<gel:log category="QUERRY" level="info" message="${data.rows.0.prName}" />
<gel:log level="INFO">After forming the XML structure</gel:log>
<gel:set asString="true" select="$val_xml" var="userBodyContent"/>
<gel:log level="INFO">’User body is ‘${userBodyContent}</gel:log>
<gel:log category="XOG" level="info" message="${val_xml}" />


<!--XOG SENDING -->
<gel:out>Session ID = ${SessionID}</gel:out>
<gel:log category="XOG" level="info"
message="Envoi du XOG pour l'affectations de colonne" />
<core:catch var="exception">
<soap:invoke endpoint="${hostClarity}/niku/xog" var="output">
<gel:log category="XOG" level="info" message="${output}" />
<soap:message>
<soapenv:Envelope>
<soapenv:Header>

<xog:Auth>
<xog:SessionID>${sessionID}</xog:SessionID>
</xog:Auth>

</soapenv:Header>
<gel:log level="INFO">Session id is ${sessionID}</gel:log>
<soapenv:Body>
<gel:include select="$val_xml" />
</soapenv:Body>
</soapenv:Envelope>
</soap:message>
</soap:invoke>
<gel:set asString="true" select="$auth/soapenv:Envelope/soapenv:Body/xog:SessionID/text()" var="sessionID"/>
<core:set value="0" var="exception" />
</core:catch>
<core:choose>
<core:when test="${exception != 0}">
<gel:log level="error" message="[-] Error while sending XOG" />
<gel:log category="SOAP" level="info" message="${exception}" />
</core:when>
<core:otherwise>
<gel:set asString="true"
select="$output//XOGOutput/ErrorInformation/Exception/text()"
var="DocErrTxt1" />
<gel:log category="XOG" level="info" message="${DocErrTxt1}" />
<gel:set asString="true"
select="$output//XOGOutput/Records/Record/ErrorInformation/Exception/text()"
var="DocErrTxt2" />
<gel:log category="XOG" level="info" message="${DocErrTxt2}" />
<core:choose>
<core:when test="${DocErrTxt1 != null || DocErrTxt2 != null}">
<gel:log category="SOAP" level="error"
message="Erreur lors de l'association de colonne !!" />
<gel:set asString="true"
select="$output//XOGOutput/Records/Record/ErrorInformation/Description/text()"
var="DescErr" />
<gel:log category="XOG" level="info" message="${DocErrTxt1}" />
<gel:log category="XOG" level="info" message="${DescErr}" />
<gel:log category="XOG" level="info" message="${DocErrTxt2}" />
<gel:set asString="true" select="$val_xml" var="xogIn" />
<gel:log category="XOG" level="info" message="$xogIn" />
</core:when>
<core:otherwise>
<gel:log category="SOAP" level="info"
message="Affectation de colonne réussie !!" />
<gel:set asString="true" select="$output" var="docOut"/>
<gel:log category="XOG" level="info" message="${docOut}"/>
</core:otherwise>
</core:choose>
</core:otherwise>
</core:choose>
</gel:script>
</scriptText>
</customScript>

_

my custom field doesn't updated with new value (xtd_export_fsp = "true") . any suggestions/remarks?

Outcomes