AnsweredAssumed Answered

Gel Script to modify XOG output

Question asked by Plidian on Oct 26, 2012
Latest reply on Aug 15, 2016 by vince
So here's what I'm trying to do. I want to read out an object in Clarity using XOG, modify one of the values in that XOG and then push it back into clarity.
I'm attempting to accomplish this with GEL and a process inside Clarity.
<gel:script 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
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:core="jelly:core" 
xmlns:sql="jelly:sql" 
xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary" 
xmlns:util="jelly:util" 
xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
xmlns:mail="jelly:email">
  
  <!-- XOG PARAMETERS -->
  <gel:parameter var="AppUser" default="admin" />
  <gel:parameter var="AppPass" default="xxxxxxx" secure="true" />
  <gel:parameter default="emails" var="Emails"/>
  <!-- CONNECTION STRING TO warmDB -->
  <!-- gel:setDataSource dbId="Niku" var="warmDB" / -->
  
       <!-- E-mail -->
    <core:set var="emailFrom" value="TestProcess" />
    <core:set var="emailServer" value="mail.server.com" />

  <!-- PREPARE SOAP BODY MESSAGE - READ COSTPLAN -->
  <gel:parse var="soapBody">
  <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_read.xsd">
    <Header version="8.0" action="read" objectType="budgetPlan" externalSource="NIKU" />
    <Query>
      <Filter name="investmentID" criteria="EQUALS">BJ9</Filter>
      <Filter name="code" criteria="EQUALS">1102251200-BJ9a</Filter>
    </Query>
  </NikuDataBus>
  </gel:parse>
  
 <!-- INVOKE XOG -->
  <soap:invoke endpoint="http://nyt-warm6-at:82/niku/xog" var="xogResponse">
    <soap:message>
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">
        <soapenv:Header>
          <xog:Auth>
            <xog:Username>${AppUser}</xog:Username>
            <xog:Password>${AppPass}</xog:Password>
          </xog:Auth>
        </soapenv:Header>
        <soapenv:Body>
        
<gel:include select="$soapBody" />
        </soapenv:Body>
      </soapenv:Envelope>
    </soap:message>
  </soap:invoke>
  <gel:set asString="true" select="$xogResponse" var="prxogResponse"/>
  
  <!-- PARSE XOG RESPONSE AND ASSIGN VARIABLES -->
  <!-- capture session id -->
  <gel:set select="$xogResponse/*/*/*/text()" asString="true" var="xogSessionID" />
 <gel:set select="$xogResponse" asString="true" var="xogTemp" />
 <util:replace new="1102251200-BJ9b" old="1102251200-BJ9a" value="${xogTemp}" var="xogTemp2"/> 
 <util:replace new="Archive Budget2" old="Archive Budget" value="${xogTemp2}" var="updatePlan"/>
<gel:parse var="parsedUpdatePlan">${updatePlan}</gel:parse>
<!-- INVOKE XOG -->
  <soap:invoke endpoint="http://nyt-warm6-at:82/niku/xog" var="xogUpdatePlan">
    <soap:message>
    
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">
                                <soap-env:Header>
                                    <xog:Auth>
                                        <xog:SessionID>${xogSessionID}</xog:SessionID>
                                    </xog:Auth>
                                </soap-env:Header>
                                <soap-env:Body>
                                    <gel:include select="$parsedUpdatePlan"/>
                                </soap-env:Body>
                            </soap-env:Envelope>
                        </soap:message>
  </soap:invoke>
  <!-- DESTROY XOG SESSION -->
  <soap:invoke endpoint="http://nyt-warm6-at:82/niku/xog" var="xogLogout">
    <soap:message>
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">
        <soapenv:Header><Auth><xog:SessionID>${xogSessionID}</xog:SessionID></Auth></soapenv:Header>
        <soapenv:Body><xog:Logout/></soapenv:Body>
      </soapenv:Envelope>
    </soap:message>
  </soap:invoke>
<gel:set asString="true" select="$parsed" var="prparsed"/>

<mail:email server="${emailServer}" from="${emailFrom}" to="${Emails}" subject="test process xog information">
</mail:email>

  
</gel:script>
The above code throws an error
null:59:35: <gel:parse> Reference is not allowed in prolog.
when the process tries to run. I've also tried using the util:replace without first converting to a string, but when I try and convert the results to a string I get an error saying the XML is invalid.
I cannot be the first person to try this but I wasn't able to find any other posts that specifically answered my use case.
Anybody see what it is I'm missing?

Outcomes