2 Replies Latest reply on Dec 13, 2007 12:21 PM by Jasmin Charbonneau

    Clear a map ?

    Level 1
      Anyone know how to remove all items in a map variable? The workbench documentation states we can replace the items in a *list* by specifying the first index:

      To replace the items in a list, you specify the index of the first item (for example, /process_data/listVar[1]).

      Is there an equivalent syntax for maps? Actually, what I'd like to do is clear all items in a map variable from a "set value" activity, not necessarily during the output of another operation.
        • 1. Re: Clear a map ?
          Level 1
          Once again, I answered my own question...

          This can be achieved with a executeScript action as hinted by the documentation here:

          See comment from Dec 5, 2007.

          So create a Execute Script activity, and paste in the following code:

          import java.util.HashMap;
          HashMap myMap = patExecContext.getProcessDataMapValue("/process_data/OutputDocMap");

          OutputDocMap is the name of my map variable in workbench.

          This works for me, but is there an easier way?
          • 2. Re: Clear a map ?
            Jasmin Charbonneau Level 4
            Another trick my be to have a temp map variable (emptyMap) which is empty and just overwrite the value of the map variable with the content with the content of the empty variable.

            /process_data/myMap = /process_data/emptyMap