Expand my Community achievements bar.

Delete list item

Avatar

Former Community Member
Hi, I have a list data type of document type. How can I replace any of the list item with a new document.



I tried doing the following for replace document in a list item:

'/process_data/@intvar' = 2

'/process_data/listvar[number(/process_data/@intvar')]' = '/prcess_data/documentNew'



Somehow, it did not replace the old list item at index 2 but instead insert the new document to the end of list? Why?



I tried another way, with the actual number:

'/process_data/listvar[2]' = '/prcess_data/documentNew'

Then, it replace the list item.



And Can I delete any of the list item, said '/process_data/listvar[2]' or the whole list.



I tried to assign a new list to another list, e.g.

'/process_data/listOne' = '/process_data/listTwo'



The result is listTwo is append to listOne, instead of replace the listOne with listTwo.



Thanks in advance...
5 Replies

Avatar

Level 9
Hi Mike

XPath indexes are 1-based rather than 0-based in Java and most other languages. So perhaps that is the only problem you're facing in the first part of your question.



The append rather than overwrite behaviour is strange - not quite sure whether it's intended for some reason, or it's a bug. We can confirm that we see the same behaviour.

What we do is if we want to assign, we clear the original list first - you can do this with our CollectionUtils component.

More info here:

http://avoka.dnsalias.com/confluence/display/Public/Collection+Utilities+DSC



Download here:

http://www.avoka.com/apps/checkcookie?qpac=y&qpac_code=avokaESComponents&location=%2Fapps%2Fqpacdown...



Howard

Avatar

Level 4
Hi,



A way to completly empty a list or map is by using a ExecuteScript object and place the following code in it:



import java.util.HashMap;

import java.util.Map;







((HashMap) patExecContext.getProcessDataValue("/process_data/inputMapOfAttachments")).clear();



Regards,



RonnyR

Avatar

Former Community Member
Hi,

Thank you all for the pointer and information...

Regards.

Avatar

Former Community Member
ES 8.2 will have a new function to empty map and list objects

Avatar

Former Community Member
The default behaviour when adding values to a list is to append the values to the list.



If you want to replace a value, you need to identify the index of the item to replace, for example /process_data/listVar[1]



Here's the help topic about accessing data in lists and maps:



http://livedocs.adobe.com/livecycle/es/wb_help/00000631.html



Scott