5 Replies Latest reply on Apr 29, 2008 7:38 AM by (Scott_Brodersen)

    Delete list item

    Level 1
      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...
        • 1. Re: Delete list item
          HowardTreisman Level 1
          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:

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

          • 2. Re: Delete list item
            Ruytero Level 1

            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();


            • 3. Re: Delete list item
              Level 1
              Thank you all for the pointer and information...
              • 4. Re: Delete list item
                Level 1
                ES 8.2 will have a new function to empty map and list objects
                • 5. Re: Delete list item
                  Level 1
                  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: