What exactly it is that you have done and ar trying to do?
If your XOG output has more output that what you want why cannot you just set the criteria so that on the instance you want comes out?
Sounds as if you want it done automatically. If so then just editing the xml file is not acceptable, otherwise the would be a simple solution.
If you are using a process with gel script to generate the xml file that same applies: you more precise criteria.
Another option is to base the xml file creation on an sql query result. Then again proper criteria will get you just the data you want.
If you get more result rows and are already using a gel script if would be simpler to get just the one record you want.
Original Message:
Sent: Mar 10, 2023 10:09 AM
From: Igor Vraniak
Subject: Extract particular instance from xogged out object
Hi Deepu,
You can achieve this by using <gel:forEach>, which let you iterate over elements of XML document. See sample script below.
<gel:script xmlns:core="jelly:core" xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary" xmlns:sql="jelly:sql" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <gel:parse var="xogXml"> <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_customObjectInstance.xsd"> <Header action="write" externalSource="NIKU" objectType="customObjectInstance" version="16.0.3.1009"/> <customObjectInstances objectCode="rbu_task_alloc"> <instance grandparentInstanceCode="JPR13567" grandparentObjectCode="rbu_proj_alloc" instanceCode="00933753" objectCode="rbu_task_alloc" parentInstanceCode="00202528" parentObjectCode="rbu_team_allocation"> <CustomInformation> <ColumnValue name="partition_code">NIKU.ROOT</ColumnValue> <ColumnValue name="code">00933753</ColumnValue> <ColumnValue name="rli_numbers">47062-1</ColumnValue> <ColumnValue name="name">Edit</ColumnValue> <ColumnValue name="input_id">02232156</ColumnValue> <ColumnValue name="alloc_distr_perc"> <tsvData default="0.0" finish="2025-12-31T00:00:00" start="2023-07-01T00:00:00" type="percentage"> <segment finish="2023-09-30T00:00:00" isDefaultSegment="false" rate="0.2" start="2023-07-01T00:00:00"/> </tsvData> </ColumnValue> </CustomInformation> </instance> <instance grandparentInstanceCode="JPR13567" grandparentObjectCode="rbu_proj_alloc" instanceCode="00933753" objectCode="rbu_task_alloc" parentInstanceCode="00202527" parentObjectCode="rbu_team_allocation"> <CustomInformation> <ColumnValue name="partition_code">NIKU.ROOT</ColumnValue> <ColumnValue name="code">00933753</ColumnValue> <ColumnValue name="rli_numbers">55297-1</ColumnValue> <ColumnValue name="name">Edit</ColumnValue> <ColumnValue name="input_id">02232171</ColumnValue> <ColumnValue name="alloc_distr_perc"> <tsvData default="0.0" finish="2023-09-30T00:00:00" start="2023-07-01T00:00:00" type="percentage"> <segment finish="2023-09-30T00:00:00" isDefaultSegment="false" rate="0.15" start="2023-07-01T00:00:00"/> </tsvData> </ColumnValue> </CustomInformation> </instance> </customObjectInstances> </NikuDataBus> </gel:parse> <gel:forEach select="$xogXml/NikuDataBus/customObjectInstances/instance" var="instance"> <gel:forEach select="$instance/CustomInformation/ColumnValue" var="columnValue"> <gel:set asString="true" select="$columnValue/@name" var="columnValueName"/> <gel:set asString="true" select="$columnValue/text()" var="columnValueText"/> <core:if test="${columnValueName eq 'input_id' and columnValueText eq '02232156'}"> <gel:set asString="false" select="$instance" var="targetInstance"/> </core:if> </gel:forEach> </gel:forEach> <gel:set var="output" select="$targetInstance" asString="true"/> <gel:log level="INFO">targetInstance: ${output}</gel:log></gel:script>
Igor
Original Message:
Sent: Mar 04, 2023 12:52 PM
From: Deepu Divakaran
Subject: Extract particular instance from xogged out object
Hi Experts,
I xogged out 2 instances of a custom object in below xml.
I am trying to extract the first instance's xml highlighted below to another variable based on the input_id column's value.
How can i do that using jelly script?
<NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_customObjectInstance.xsd">
<Header action="write" externalSource="NIKU" objectType="customObjectInstance" version="16.0.3.1009"/>
<customObjectInstances objectCode="rbu_task_alloc">
<instance grandparentInstanceCode="JPR13567"
grandparentObjectCode="rbu_proj_alloc"
instanceCode="00933753" objectCode="rbu_task_alloc"
parentInstanceCode="00202528" parentObjectCode="rbu_team_allocation">
<CustomInformation>
<ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>
<ColumnValue name="code">00933753</ColumnValue>
<ColumnValue name="rli_numbers">47062-1</ColumnValue>
<ColumnValue name="name">Edit</ColumnValue>
<ColumnValue name="input_id">02232156</ColumnValue>
<ColumnValue name="alloc_distr_perc">
<tsvData default="0.0" finish="2025-12-31T00:00:00" start="2023-07-01T00:00:00" type="percentage">
<segment finish="2023-09-30T00:00:00" isDefaultSegment="false" rate="0.2" start="2023-07-01T00:00:00"/>
</tsvData>
</ColumnValue>
</CustomInformation>
</instance>
<instance grandparentInstanceCode="JPR13567"
grandparentObjectCode="rbu_proj_alloc"
instanceCode="00933753" objectCode="rbu_task_alloc"
parentInstanceCode="00202527" parentObjectCode="rbu_team_allocation">
<CustomInformation>
<ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>
<ColumnValue name="code">00933753</ColumnValue>
<ColumnValue name="rli_numbers">55297-1</ColumnValue>
<ColumnValue name="name">Edit</ColumnValue>
<ColumnValue name="input_id">02232171</ColumnValue>
<ColumnValue name="alloc_distr_perc">
<tsvData default="0.0" finish="2023-09-30T00:00:00" start="2023-07-01T00:00:00" type="percentage">
<segment finish="2023-09-30T00:00:00" isDefaultSegment="false" rate="0.15" start="2023-07-01T00:00:00"/>
</tsvData>
</ColumnValue>
</CustomInformation>
</instance>
</customObjectInstances>
</NikuDataBus>
regards,
Deepu.