Expand my Community achievements bar.

Clear a map ?

Avatar

Former Community Member
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:



(quote)

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

(end-quote)



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.
2 Replies

Avatar

Former Community Member
Once again, I answered my own question...



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

http://livedocs.adobe.com/livecycle/es/wb_help/00000856.html#wp1709233



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

myMap.clear();



OutputDocMap is the name of my map variable in workbench.



This works for me, but is there an easier way?

Avatar

Level 10
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



Jasmin