AnsweredAssumed Answered

Error while attempting to create instances of Custom Sub-Object

Question asked by AshwinKumar_MASSIT on Oct 29, 2015
Latest reply on Oct 29, 2015 by AshwinKumar_MASSIT

I am attempting to use GEL scripting to create instances of a custom sub-object of the Resource object. The ID and name of the custom sub-object are set to be auto-numbered, which is why the GEL has the header tag argument of "overrideAutoNumbering" set to false. Per another discussion thread I noticed that the instance code, code, and name need to be set to -1, which is also there in the Gel script.

 

If I take the XML document created by the Gel:Serialize statement and run the XOG on the command line it works and the custom object instance gets created.

 

I need guidance in overcoming this challenge because we have to create more GEL scripts which would be similar.

 

Error while executing the Gel Script

<?xml version="1.0" encoding="UTF-8"?>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <soapenv:Header/>

  <soapenv:Body>

    <XOGOutput xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/status.xsd">

      <Object type="customObjectInstance"/>

      <Status elapsedTime="0.109 seconds" state="SUCCESS"/>

      <Statistics failureRecords="1" insertedRecords="0" totalNumberOfRecords="1" updatedRecords="0"/>

      <Records>

        <Record>

          <KeyInformation>

            <column name="resource_sow">-1</column>

          </KeyInformation>

          <ErrorInformation>

            <Severity>FATAL</Severity>

            <Description>com.niku.union.odf.exception.ODFServiceException: &lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;insertService type="java" componentId="odf" description="com.niku.odf.service.object.CustomObjectInsertService" transaction="dbTransaction" xmlns="http://schemas.niku.com/2002/objectTypes"/&gt;

 

 

Caused by: id: odf.objectIllegalCreate location:  type: error value: 

</Description>

          </ErrorInformation>

        </Record>

      </Records>

    </XOGOutput>

  </soapenv:Body>

</soapenv:Envelope>

 

 

Code for the GEL Script

<gel:script

        xmlns:SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope/"

        xmlns:core     = "jelly:core"

        xmlns:file="jelly:com.niku.union.gel.FileTagLibrary"

        xmlns:gel      = "jelly:com.niku.union.gel.GELTagLibrary"

        xmlns:soap     = "jelly:com.niku.union.gel.SOAPTagLibrary"

        xmlns:soap-env = "http://schemas.xmlsoap.org/soap/envelope/"

        xmlns:sql      = "jelly:sql"

        xmlns:util     = "jelly:util"

        xmlns:xog      = "http://www.niku.com/xog"

        xmlns:xsi      = "http://www.w3.org/2001/XMLSchema-instance">

 

 

        <gel:parameter default="http://localhost:80" var="XOGURL"/>

        <gel:parameter default="xog.administrator" var="XOGUsername"/>

        <gel:parameter default="niku2000" secure="true" var="XOGPassword"/>

        <gel:parameter default="Commonwealth_of_MA_Rate_Matrix" secure="true" var="Rate_Card_Title"/>

 

 

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

        <!-- Get  DB Connection to Clarity -->

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

        <gel:setDataSource dbId="Niku" var="clarityDS"/>

 

 

 

 

        <gel:log> Rate Card: ${Rate_Card_Title} </gel:log>

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

        <!--  Retrieve the resource availability hours  -->

        <gel:log>  Getting ready to retrieve the resource rates ${gel_objectInstanceId} </gel:log>

        <sql:catch var="rateDataReadError">

                <sql:query dataSource="${clarityDS}" escapeText="false" var="laborRateCursor">

                       <![CDATA[select distinct res.id             as "Resource_DBID",

                                                ratecard.value2    as "Resource_Code",

                                                initcap(trim(res.first_name) || ' ' || trim(res.last_name)) as "Resource_Name",

                                                role.id            as "Role_DBID",

                                                ratecard.value3    as "Role_Code",

                                                apm.id             as "Vendor_XREFID",

                                                resfin.vendor_code as "Vendor_Code",

                                                initcap(trim(apm.address_name)) as "Vendor_Name",

                                                ratecard.fromdate  as "From_Date",

                                                ratecard.todate    as "To_Date",

                                                ratecard.numval3   as "Billing_Rate"

                                from            ppa_matrixvalues  ratecard

                                inner join      srm_resources     res        on (res.unique_name = ratecard.value2 and res.is_active = 1)

                                left  join      srm_resources     role       on (role.unique_name = ratecard.value3 and res.is_active = 1)

                                inner join      ppa_matrix        rateMaster on (

                                                                                  rateMaster.matrixkey   = ratecard.matrixkey   and

                                                                                  rateMaster.description = '${Rate_Card_Title}' and

                                                                                  rateMaster.matrixtype  = 'R'

                                                                                )

                                inner join      PAC_MNT_RESOURCES resfin     on (resfin.id       = res.id and resfin.active = 1)

                                inner join      apmaster          apm        on (apm.vendor_code = resfin.vendor_code)

                                where ratecard.value2 is not null and ratecard.value3 is not null

                                order by "Resource_Name"

                         ]]>

                </sql:query>

        </sql:catch>

 

 

        <core:set value = "0"  var = "successfulRead"/>

 

 

        <core:choose>

                 <core:when test="${rateDataReadError == null}">

 

 

                          <core:forEach items = "${laborRateCursor.rowsByIndex}" var = "resultArray">

                                   <core:set value = "${resultArray[0]}"     var = "resource_dbid"/>

                                   <core:set value = "${resultArray[1]}"     var = "resource_code"/>

                                   <core:set value = "${resultArray[2]}"     var = "resource_name"/>

                                   <core:set value = "${resultArray[3]}"     var = "role_dbid"/>

                                   <core:set value = "${resultArray[4]}"     var = "role_code"/>

                                   <core:set value = "${resultArray[5]}"     var = "vendor_xrefid"/>

                                   <core:set value = "${resultArray[6]}"     var = "vendor_code"/>

                                   <core:set value = "${resultArray[7]}"     var = "vendor_name"/>

                                   <core:set value = "${resultArray[8]}"     var = "rate_fromdate"/>

                                   <core:set value = "${resultArray[9]}"     var = "rate_todate"/>

                                   <core:set value = "${resultArray[10]}"   var = "billing_rate"/>

                                   <core:set value = "1"  var = "successfulRead"/>

                          </core:forEach>

                          <core:if test="${successfulRead == 1}">

 

 

                               <gel:log> Successfully retrieved labor rates</gel:log>

                               <core:set value="${XOGURL}/niku/xog" var="XOGURL"/>

                               <gel:log level="info" message="XOG URL:${XOGURL} "/>

                               <gel:log level="info" message="XOG Username:${XOGUsername} "/>

                               <gel:log level="info" message="XOG Password:${XOGPassword} "/>

                               <!--  ************************************************* Get the Gel Body  ************************************************* -->

                               <gel:parse var="xog_info">

 

 

                                    <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:/Niku/Clarity/xog-unzipped/xsd/nikuxog_user.xsd">

                                         <Header action="write" externalSource="NIKU" objectType="customObjectInstance" version="14.2.0.3.10">

                                              <args name="overrideAutoNumbering" value="false"/>

                                         </Header>

 

 

                                         <core:set value = "- SOW"                var = "sow_name_suffix"/>

                                         <core:set value = "USD"                  var = "currency_code"/>

                                         <core:set value = "1875"                 var = "contracted_hours"/>

                                         <core:set value = "2015-07-01T00:00:00"  var = "sow_start_date"/>

                                         <core:set value = "2016-06-30T00:00:00"  var = "sow_end_date"/>

                                         <core:set value = "true"                 var = "is_true"/>

                                         <core:set value = "false"                var = "is_false"/>

                                         <core:set value = "-1"                   var = "instanceCode"/>

 

 

                                         <customObjectInstances objectCode="resource_sow">

                                              <core:forEach items = "${laborRateCursor.rowsByIndex}" var = "resultArray">

                                                   <core:set value = "${resultArray[0]}"      var = "resource_dbid"/>

                                                   <core:set value = "${resultArray[1]}"      var = "resource_code"/>

                                                   <core:set value = "${resultArray[2]}"      var = "resource_name"/>

                                                   <core:set value = "${resultArray[3]}"      var = "role_dbid"/>

                                                   <core:set value = "${resultArray[4]}"      var = "role_code"/>

                                                   <core:set value = "${resultArray[5]}"      var = "vendor_xrefid"/>

                                                   <core:set value = "${resultArray[6]}"      var = "vendor_code"/>

                                                   <core:set value = "${resultArray[7]}"      var = "vendor_name"/>

                                                   <core:set value = "${resultArray[8]}"      var = "rate_fromdate"/>

                                                   <core:set value = "${resultArray[9]}"      var = "rate_todate"/>

                                                   <core:set value = "${resultArray[10]}"    var = "billing_rate"/>

                                                   <gel:log> Successfully retrieved rate details for ${resource_name}</gel:log>

 

 

                                                   <instance instanceCode="${instanceCode}" objectCode="resource_sow" parentInstanceCode="${resource_code}" parentObjectCode="resource">

                                                        <CustomInformation>

                                                             <ColumnValue name = "sow_currency_code">${currency_code}</ColumnValue>

                                                             <ColumnValue name = "contracted_hours">${contracted_hours}</ColumnValue>

                                                             <ColumnValue name = "sow_start_date">${sow_start_date}</ColumnValue>

                                                             <ColumnValue name = "contractual_role">${role_dbid}</ColumnValue>

                                                             <ColumnValue name = "name">${instanceCode}</ColumnValue>

                                                             <ColumnValue name = "code">${instanceCode}</ColumnValue>

                                                             <ColumnValue name = "odf_parent_id">${resource_dbid}</ColumnValue>

                                                             <ColumnValue name = "odf_cncrt_parent_id">${resource_dbid}</ColumnValue>

                                                             <ColumnValue name = "sow_vendor">${vendor_xrefid}</ColumnValue>

                                                             <ColumnValue name = "hourly_rate">${billing_rate}</ColumnValue>

                                                             <ColumnValue name = "hourly_rate_currency">${currency_code}</ColumnValue>

                                                             <ColumnValue name = "sow_end_date">${sow_end_date}</ColumnValue>

                                                             <ColumnValue name = "is_active">${is_false}</ColumnValue>

                                                             <ColumnValue name = "reload_snapshots">${is_false}</ColumnValue>

                                                        </CustomInformation>

                                                   </instance>

                                              </core:forEach>

                                         </customObjectInstances>

                                    </NikuDataBus>

                               </gel:parse>

 

 

                               <!--  ************************************************* Log in and Execute the XOG  ************************************************* -->

                               <core:catch var="XOGerror">

                                    <!--  ********************************************************** Log into Clarity  ********************************************************** -->

                                    <soap:invoke endpoint="${XOGURL}" var="auth">

                                         <soap:message>

                                              <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">

                                                   <soap-env:Body>

                                                        <xog:Login>

                                                             <xog:Username>${XOGUsername}</xog:Username>

                                                             <xog:Password>${XOGPassword}</xog:Password>

                                                        </xog:Login>

                                                   </soap-env:Body>

                                              </soap-env:Envelope>

                                         </soap:message>

                                    </soap:invoke>

                                    <!--  ********************************************************** Verify Log in  ********************************************************** -->

                                    <gel:set asString="true" select="$auth/SOAP-ENV:Envelope/SOAP-ENV:Body/xog:SessionID/text()" var="sessionID"/>

                                    <core:choose>

                                         <core:when test="${sessionID == null}">

                                              <gel:log level="ERROR">ERROR: Login to Clarity XOG failed. Check username and password.</gel:log>

                                         </core:when>

                                         <core:otherwise>

                                              <gel:log>SUCCESS: Login to Clarity XOG successful.</gel:log>

                                              <!--  ********************************************************** Execute the XOG Query  ********************************************************** -->

                                              <soap:invoke endpoint="${XOGURL}" var="result">

                                                   <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>${sessionID}</xog:SessionID>

                                                                  </xog:Auth>

                                                             </soap-env:Header>

                                                             <gel:log> Getting ready to execute XOG</gel:log>

                                                             <gel:serialize fileName="C:/Niku/Clarity/xog-unzipped/2015-10-29-RateCardImport.xml" var="${xog_info}"/> 

                                                             <soap-env:Body>

                                                                  <gel:include select="$xog_info/NikuDataBus"/>

                                                             </soap-env:Body>

                                                        </soap-env:Envelope>

                                                   </soap:message>

                                              </soap:invoke>

                                              <gel:serialize fileName="C:/Niku/Clarity/xog-unzipped/2015-10-29-RateCardImportResult.xml" var="${result}"/> 

                                         </core:otherwise>

                                    </core:choose>

                               </core:catch>

 

 

                               <!--  ********************************************************** Verify execution status  ********************************************************** -->

                               <core:choose>

                                    <core:when test="${XOGerror == null}">

                                         <gel:log>XOG Completed with out errors  ${XOGerror} </gel:log>

                                    </core:when>

                                    <core:otherwise>

                                         <gel:log level="ERROR">ERROR: XOG error : ${XOGerror} </gel:log>

                                    </core:otherwise>

                               </core:choose>

                               <!--  ********************************************************** Log out of Clarity  ********************************************************** -->

                               <soap:invoke endpoint="${XOGURL}" var="result">

                                    <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>${sessionID}</xog:SessionID>

                                                   </xog:Auth>

                                              </soap-env:Header>

                                              <soap-env:Body>

                                                   <xog:Logout/>

                                                   <gel:log>SUCCESS: Logout to Clarity XOG successful.</gel:log>

                                              </soap-env:Body>

                                         </soap-env:Envelope>

                                    </soap:message>

                               </soap:invoke>

                          </core:if>

                 </core:when>

                 <core:otherwise>

                          <gel:log level="ERROR">ERROR: Retrieval of labor rates has failed ${rateDataReadError}</gel:log>

                 </core:otherwise>

        </core:choose>

</gel:script>

Outcomes