Clarity

 View Only
Expand all | Collapse all

Updating Project Instance Rights via Xog

  • 1.  Updating Project Instance Rights via Xog

    Posted Apr 21, 2015 04:56 PM

    I have built an object that houses project instance rights, for a given resource there could be multiple projects the resource has instance rights to. I'm trying to write a process that xogs in a new project to the instance rights object, but every time I xog in the instance rights it overwrites whatever values exist currently. Is there a way to update without overwriting the current projects? Thanks!  



  • 2.  Re: Updating Project Instance Rights via Xog

    Posted Apr 22, 2015 04:08 AM

    I'm not sure I follow your question (I'm confused between what is a custom object, whether you are talking about Clarity instance rights or attributes of your custom object that you have called 'instance rights') - perhaps if I say what I think you are saying;

     

    You are using a custom-object-write XOG call, but you are not getting new instances, only updating the one existing instance.

     

    if thats right - then check that you are giving each new version of the instance in the XML a new 'instanceCode' value in the <instance> header and the same value in the 'code' in the <CustomInformation> section.  (those values are the identifier of the instance, if you are not changing them then all you are doing is an "update" not an "insert")

     

    (and apologies if I've misunderstood)



  • 3.  Re: Updating Project Instance Rights via Xog

    Posted Apr 22, 2015 08:12 AM

    Dave,

     

    I'm using a custom object instance write xog. But is it possible to keep the same instance code and just insert a new value without overwriting whatever values are currently assigned to that instance code? Sorry for the confusion. Thanks!



  • 4.  Re: Updating Project Instance Rights via Xog

    Posted Apr 22, 2015 08:20 AM

    Are you including the attributes (set to "") that you don't want updating in the XML that you are sending - if you are then that will be treated as an update ; I think if you exclude the attribute totally then it doesn't get updated (this is true for normal objects, can't say I'm 100% sure it is true for custom objects).

     

    If that fails, is there any reason you can't just send the values (that you don't want updated) again in the XML - i.e. read out the instance (to XML), change the attributes you want to, write it back in again.

     

    (I'm still not sure I understand what you are doing though )



  • 5.  Re: Updating Project Instance Rights via Xog

    Posted Apr 22, 2015 08:34 AM

    Dave,

     

    Yeah it must not work for custom objects. I can read them out and then write them back in with the new values. Just wanted to see if there was an easier way. I heard that there was some kind of gel tag you could include that would tell the custom object instances not to overwrite what values were already in there. I'll try to more clearly explain what I'm doing....

     

    Here is the output of a write via the xog client:

     

    <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.3.0.286"/>

      <customObjectInstances objectCode="prj_inst_rights">

      <instance instanceCode="00000006" objectCode="prj_inst_rights">

      <CustomInformation>

      <ColumnValue name="prj">

      <Value>5003758</Value>

      <Value>5006985</Value>

      <Value>5007196</Value>

      <Value>5007404</Value>

      <Value>5010853</Value>

      <Value>5087751</Value>

      <Value>5106745</Value>

      <Value>5180747</Value>

      <Value>5183769</Value>

      <Value>5184769</Value>

      <Value>5210744</Value>

      <Value>5210749</Value>

      <Value>5236751</Value>

      <Value>5237763</Value>

      <Value>5238745</Value>

      <Value>5238746</Value>

      <Value>5238747</Value>

      <Value>5239744</Value>

      <Value>5253768</Value>

      <Value>5254782</Value>

      </ColumnValue>

     

    There are multiple values for the column name "prj".

     

    In my gel script, I just include the new value to add to the prj column, and it was my understanding it would just insert a new record into that column.

     

    <gel:parse var="update_prj_inst_rights">

       <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.3.0.286"/>

      <customObjectInstances objectCode="prj_inst_rights">

                               <instance instanceCode="${ir_unique_code}" objectCode="prj_inst_rights">

      <CustomInformation>

      <ColumnValue name="prj">

      <Value>${prj_id}</Value>

             </ColumnValue>

             <ColumnValue name="assign">false</ColumnValue>

      <ColumnValue name="res">${prj_mgr_racf}</ColumnValue>

      <ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>

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

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

      <ColumnValue name="page_layout">odf.prj_inst_rightsFrame</ColumnValue>

      <ColumnValue name="odf_period_start"/>

      <ColumnValue name="odf_period_end"/>

      </CustomInformation>

      <OBSAssocs complete="false"/>

      </instance>

     

         </customObjectInstances>

       </NikuDataBus> 

       </gel:parse>

     

    Everytime I run my gel script, it takes the value for prj_id and overwrites whatever values were previously stored in the prj column. Does that make more sense? Thanks!



  • 6.  Re: Updating Project Instance Rights via Xog
    Best Answer

    Posted Apr 22, 2015 08:39 AM

    OK I see - your "prj" is a multi-valued lookup attribute.

     

    So pretty sure you can't do what you are trying to at all then (on a normal object nor custom), because the attribute is "prj" you are explicitly re-writing it each time you send the XML.  If there were multiple attributes you could omit them from the XML and they would not get overwritten (for example you could omit your "res" attribute and it wouldn't get updated).

     

    --

     

    So in your GEL script, you could read (via SQL) the existing values and include them in the XML.



  • 7.  Re: Updating Project Instance Rights via Xog

    Posted Apr 22, 2015 08:42 AM

    Dave,

     

    Alright that's what I'll do. Thanks for your help!



  • 8.  Re: Updating Project Instance Rights via Xog

    Posted Apr 27, 2015 03:46 PM

    Dave,

     

    So I'm still having some issues getting this to work correctly with your suggestion. Could you please provide some feedback/suggestions to what I am doing wrong? I'm reading out the file, storing it to memory, and then inserting the new project id into the correct node. But it isn't updating. I don't get a failure or any errors. Just don't see the new value. Any suggestions?

     

     

    <gel:parse var="loadRights">

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

       <Header version="8.0" action="read" objectType="customObjectInstance" externalSource="NIKU"/>

       <CustomObjectInstanceQuery>

         <Filter name="objectCode" criteria="EQUALS">prj_inst_rights</Filter>

         <Filter name="instanceCode" criteria="EQUALS">${ir_unique_code}</Filter>

            

       </CustomObjectInstanceQuery>

      

      </NikuDataBus>

      </gel:parse>

     

      <gel:log level="info">Outputting the read file of all prj_inst_rights for code ${ir_unique_code}</gel:log>

      <gel:log>

      <gel:expr select="$loadRights"/>

      </gel:log>

     

     

      <soap:invoke endpoint="${XOGURL}/niku/xog" var="updateRecord">

       <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="$loadRights"/>

      </soapenv:Body>

      </soapenv:Envelope>

       </soap:message>

      </soap:invoke>

      

      <gel:log>

        <gel:expr select="$updateRecord"/>

      </gel:log>

                    

     

                      <gel:parse var="insertRight">

                     

                      <Value>${prj_id}</Value>

                     

                     </gel:parse>

                       

                       

                       

                       

                        <gel:set insert="true" select="$updateRecord/NikuDataBus/Header/customObjectInstances/instance/CustomInformation/ColumnValue/@prj" var="${insertRight}"/>

     

    <gel:log>

        <gel:expr select="$updateRecord"/>

      </gel:log>



  • 9.  Re: Updating Project Instance Rights via Xog

    Posted Apr 28, 2015 05:15 AM

    Sorry I'm not really any help here (I don't really get this XPATH stuff) - I wonder if the problem is that the thing that you are adding detail to its not really an XML node, its a repeating value within a node - so perhaps you need to write back into the XML the whole node (rather than just the single new value).

     

    i.e. you have to write back in the whole "prj" thing(or even the whole "CustomInformation" bit) - but I'm GUESSing a lot here.



  • 10.  Re: Updating Project Instance Rights via Xog

    Posted Apr 28, 2015 09:27 AM

    This should be close...

     

    <gel:set insert="true" select="$updateRecord/NikuDataBus/customObjectInstances/instance/CustomInformation/ColumnValue[@name='prj']" var="${insertRight}"/>
    


  • 11.  Re: Updating Project Instance Rights via Xog

    Posted Apr 28, 2015 10:32 AM

    Andrew,

     

    Thanks for the advice, but I've already tried that. Still no cigars. Is my node naming convention wrong? Shouldn't var be value because its referencing an attribute name in the select statement?

     

    Here is a copy of my formatted output, which is the same as my $updateRecord before I try to insert the new record :

    <?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>

    <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.3.0.286"/>

    <customObjectInstances objectCode="prj_inst_rights">

    <instance instanceCode="00000104" objectCode="prj_inst_rights">

    <CustomInformation>

    <ColumnValue name="prj">

    <Value>5275761</Value>

    </ColumnValue>

    <ColumnValue name="assign">false</ColumnValue>

    <ColumnValue name="res">S3038</ColumnValue>

    <ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>

    <ColumnValue name="name">00000104</ColumnValue>

    <ColumnValue name="code">00000104</ColumnValue>

    <ColumnValue name="page_layout">odf.prj_inst_rightsFrame</ColumnValue>

    <ColumnValue name="odf_period_start"/>

    <ColumnValue name="odf_period_end"/>

    </CustomInformation>

    <OBSAssocs complete="false"/>

    <Security>

    <UserSecurity rightCode="odf_cst_prj_inst_rights_edit" userName="admin"/>

    </Security>

    </instance>

    </customObjectInstances>

    <XOGOutput>

    <Object type="customObjectInstance"/>

    <Status state="SUCCESS"/>

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

    <Records/>

    </XOGOutput>

    </NikuDataBus>

    </soapenv:Body>

    </soapenv:Envelope>

     

     

    Although its interesting when I change var to value, I get an error stating that the node doesn't exist:

    <null> <gel:set> attribute 'select' $updateRecord/NikuDataBus/customObjectInstances/instance/CustomInformation/ColumnValue[@name='prj'] does not refer to an existing node

    But from what I can tell, the node does exist which is perplexing.



  • 12.  Re: Updating Project Instance Rights via Xog

    Posted Apr 28, 2015 10:39 AM

    You had 2 problems before: you had the Header element in the path and your attribute filter was wrong (well, it didn't exist).

     

    Try this one:

     

    <gel:set insert="true" select="$updateRecord//customObjectInstances/instance/CustomInformation/ColumnValue[@name='prj']" var="${insertRight}"/>
    
    

     

    edit: fixed to ignore the envelope wrapper in the returned document



  • 13.  Re: Updating Project Instance Rights via Xog

    Posted Apr 28, 2015 11:22 AM

    Andrew,

     

    Unfortunately that still didn't work..Still getting the same issue. It's not inserting anything. Should I not see any of the envelope wrapper in my output? I apologize for my ignorance. I'm still new at this, and have been trying to get this to work.  :

     

    <?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>

      <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.3.0.286"/>

      <customObjectInstances objectCode="prj_inst_rights">

      <instance instanceCode="00000104" objectCode="prj_inst_rights">

      <CustomInformation>

      <ColumnValue name="prj">

      <Value>5275761</Value>

      </ColumnValue>

      <ColumnValue name="assign">false</ColumnValue>

      <ColumnValue name="res">S3038</ColumnValue>

      <ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>

      <ColumnValue name="name">00000104</ColumnValue>

      <ColumnValue name="code">00000104</ColumnValue>

      <ColumnValue name="page_layout">odf.prj_inst_rightsFrame</ColumnValue>

      <ColumnValue name="odf_period_start"/>

      <ColumnValue name="odf_period_end"/>

      </CustomInformation>

      <OBSAssocs complete="false"/>

      <Security>

      <UserSecurity rightCode="odf_cst_prj_inst_rights_edit" userName="admin"/>

      </Security>

      </instance>

      </customObjectInstances>

      <XOGOutput>

      <Object type="customObjectInstance"/>

      <Status state="SUCCESS"/>

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

      <Records/>

      </XOGOutput>

      </NikuDataBus>

      </soapenv:Body>

    </soapenv:Envelope>



  • 14.  Re: Updating Project Instance Rights via Xog

    Posted Apr 28, 2015 11:31 AM

    var="${insertRight}" should be value="${insertRight}"



  • 15.  Re: Updating Project Instance Rights via Xog

    Posted Apr 28, 2015 12:49 PM

    Andrew,

     

    That did it! Thanks so much for your help!! I really appreciate it!



  • 16.  Re: Updating Project Instance Rights via Xog

    Posted Apr 28, 2015 11:45 AM

    you don't show where you XOG your update back in, but I suppose the include bit should look like this...

     

    <soapenv:Body>
      <gel:include select="$loadRights//NikuDataBus"/>
    </soapenv:Body>