cancel
Showing results for 
Search instead for 
Did you mean: 

Simple UDF for queues

silentbull
Participant
0 Kudos

Hello

I am struggling with an XML file where the structure looks like this.

<task taskName="GRN Capture" taskStartTime="2015-09-25T10:14:26.217" taskEndTime="2015-09-25T10:14:53.423">

                  <activity activityName="Image" text="" activityImageNo="1D00456B-07CD-49F9-8F89-568816C54020"/>

                  <activity activityName="Text Input" text="706061"/>

               </task>

               <task taskName="Asset Deliveries" taskStartTime="2015-09-25T10:14:55.803" taskEndTime="2015-09-25T10:15:06.457" imageNo="TR010000005C0F020F6B991EF710759BD37D8FCC4382751897E9597715">

                  <activity activityName="BB Basket" text="" number="4.000"/>

                  <activity activityName="Metal Wheel" text="" number="1.000"/>

               </task>

               <task taskName="Asset Returns" taskStartTime="2015-09-25T10:15:07.307" taskEndTime="2015-09-25T10:15:17.110">

                  <activity activityName="BB Basket" text="" number="3.000"/>

                  <activity activityName="Metal Wheel" text="" number="1.000"/>

               </task>

I want to retrieve the value of text="706061"/> where taskname ='GRN Capture'. 

My issue is this taskname GRN can come in any of the position in the task and the subsequent asset deliveries and asset returns might or might not have an activity node. Due to various combinations, my useoneasmany or graphical mapping is not working.

Is there a simple udf where i can retrieve the text = 706061 with the taskname GRN capture which will cater all the permutations and combinations.

Appreciate if you can post that with the parameters as well that i need to pass.

Regards

Sam

Accepted Solutions (1)

Accepted Solutions (1)

radek_rucinski
Explorer
0 Kudos

Hello Sam,

I would not go for UDF in this case, as it still requires playing around with contexts. Have you already tried formatByExample function? Together with mapWithDefault and correctly set context it should solve your issue.

Regards,

Radek

silentbull
Participant
0 Kudos

Hello

I had tried. It works for all cases except when the GRN capture comes as last node where there is no activity node for the rest of the two nodes. This case is not working.

radek_rucinski
Explorer
0 Kudos

If it is because of missing values please try mixed approach: mapWithDefault to ensure that there are no empty values and simple UDF (type all values of queue) to map fields based on activityName:

for (int i=0; i < activityName.length;i++)

{

if (activityName[i].equalsIgnoreCase("Text Input"))

{ result.addValue(text[i]);

}

}

One more question, how many occurences of text="706061" are required in a target message? If it is one or one per higher level node maybe you should try mapping variable?

silentbull
Participant
0 Kudos

only one GRN capture per xml file, so only one text input. The probelm is text input field might attribute in other tasks as well, so need to be careful with this.

radek_rucinski
Explorer
0 Kudos

Then it is even easier Please try mapping as below:

'And' function plays here the key role.

silentbull
Participant
0 Kudos

Hello Rado

All my scenarious had worked with your design, except one where if there is no task node at all in the entire xml, the mapping fails.

silentbull
Participant
0 Kudos

But I have sorted that as well where i have checked using exists function. Thanks for your help.

radek_rucinski
Explorer
0 Kudos

You are welcome!

Answers (0)