AnsweredAssumed Answered

Invalid parent object instance?

Question asked by twhite23 on Mar 10, 2014
Latest reply on Mar 11, 2014 by Chris Wuenstel

Below is a "safe" version of the code I am using to try to import parent and child objects. I am not sure what what to input for the parent ID. Is there some sort of query I need to input? Where do I put this query?

I originally tried to input all the parent records, read the information, then go back in insert the sub-objects and link them to the appropriate parent record based off a "parent_ID"  column. This didn't work, so this is my attmept to input both the parent and child objects at the same time.

For each time, I've tried I get an error saying "Invalid parent object instance for object PARENT while importing instance child for object PARENT.

Anyone know what this means?

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

<gel:script
xmlns:x="jelly:xml"
xmlns:core="jelly:core"
xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"
xmlns:file="jelly:com.niku.union.gel.FileTagLibrary"
xmlns:soap-env="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:parameter default="http://localhost" var="XOGURL"/>
    <gel:parameter var="XOGusername" default="xyz"/>
    <gel:parameter var="XOGpassword" default="123"/>
    <gel:parameter var="infolder" default="C:\xog\bin"/>
    <gel:parameter var="infilename" default="PEO_STRI_XOG.txt"/>
    <gel:parameter var="infile" default="${infolder}\${infilename}"/>

<soap:invoke endpoint="${XOGURL}/niku/xog" var="xog_login">
    <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 xmlns="http://www.niku.com/xog">
                    <xog:Username>${XOGusername}</xog:Username>
                    <xog:Password>${XOGpassword}</xog:Password>
                </xog:Login>
            </soap-env:Body>
        </soap-env:Envelope>
    </soap:message>
</soap:invoke>

    <gel:set var="sessionID" asString="true" select="$xog_login/soap-env:Envelope/soap-

env:Body/xog:SessionID/text()"/>
<core:choose>
    <core:when test="${sessionID == null}">
        <gel:out>Couldn't Log in. Check the username/password.</gel:out>
    </core:when>
<core:otherwise>
    <gel:out>    <gel:expr select="$xog_login"/> </gel:out>
<!-- Open up the input file -->
    <file:readFile fileName="${infile}" delimiter="\t" var="infileParsed"

embedded="false"/>  

    <!-- Skip the column headers on the first line -->
    <core:forEach items="${infileParsed.rows}" var="col" indexVar="i" begin="1" step="1">
<!--  ======= order of columns in my tab-delimited file moved to variables

===================   -->

        <core:set var="ABC" value= "${col[0]}"/>
        <core:set var="DEF" value= "${col[1]}"/>
        <core:set var="GHI" value= "${col[2]}"/>
        <core:set var="JKL" value= "${col[3]}"/>
        <core:set var="MNO" value= "${col[4]}"/>
        <core:set var="PQR" value= "${col[5]}"/>
        <core:set var="STU" value= "${col[6]}"/>
        <core:set var="VWX" value= "${col[7]}"/>

        <soap:invoke endpoint="${XOGURL}/niku/xog" var="XOG_result">
            <soap:message>
                <soap-env:Envelope

xmlns:soapenv="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>
<!--  =================================================   -->
<!--  Insert your XOG out format for your custom object   -->
<!--  =================================================   -->

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

xsi:noNamespaceSchemaLocation="../xsd/nikuxog_customObjectInstance.xsd">

  <Header action="write" externalSource="NIKU" objectType="customObjectInstance"

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

  <customObjectInstances objectCode="parent_object">
    <instance instanceCode="parent" objectCode="parent_object">

      <CustomInformation>

<!--  ======= required fields =========================   -->
        <ColumnValue name="name">AUTO-NAME</ColumnValue>
        <ColumnValue name="code">-1</ColumnValue>
<!--
        <ColumnValue name="page_layout">odf.parent_objectFrame</ColumnValue>
        <ColumnValue name="code">parent</ColumnValue>
-->

<!--  ======= custom fields  ==========================   -->
   <ColumnValue name="r_abc">${ABC}</ColumnValue>
        <ColumnValue name="r_def">${DEF}</ColumnValue>
        <ColumnValue name="r_ghi">${GHI}</ColumnValue>
       
<instance instanceCode="child" objectCode="child_object"

parentInstanceCode="parent" parentObjectCode="parent_object">
          <CustomInformation>

<!--  ======= required fields =========================   -->
            <ColumnValue name="name">AUTO-NAME</ColumnValue>
            <ColumnValue name="code">-1</ColumnValue>
            <ColumnValue name="odf_parent_id">???</ColumnValue>
            <ColumnValue name="odf_cncrt_parent_id">??</ColumnValue>
            <ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>

<!--  ======= custom fields  ==========================   -->
<ColumnValue name="r_jkl">${JKL}</ColumnValue>
            <ColumnValue name="r_mno">${MNO}</ColumnValue>
            <ColumnValue name="r_pqr">${PQR}</ColumnValue>
            <ColumnValue name="r_stu">${STU}</ColumnValue>
            <ColumnValue name="r_vwx">${VWX}</ColumnValue>

          </CustomInformation>
  <OBSAssocs complete="false"/>
        </instance>
      </CustomInformation>
      <OBSAssocs complete="false"/>
    </instance>
  </customObjectInstances>
</NikuDataBus>
                    </soap-env:Body>
                </soap-env:Envelope>
            </soap:message>
        </soap:invoke>

Outcomes