It is a very common need to clear the contents of a list or a map, especially when you are constructing a list or a map inside a loop.In LC 8.2 we have added a function to which allows you to clear the list/map contents
But for those of you using previous versions you can copy the following script and paste it in the ExecuteScript component
import java.util.*;
ArrayList list = patExecContext.getProcessDataValue(“/process_data/listOfPrincipalRef”);
((HashMap) patExecContext.getProcessDataValue(“/process_data/inputMapOfAttachments”)).clear();
System.out.println(“******Got list ,size is “+list.size());
((ArrayList) patExecContext.getProcessDataValue(“/process_data/listOfPrincipalRef”)).clear();
System.out.println(“******Got List,size is “+list.size());
Where listOfPrincipalRef is a list variable defined in your process,inputMapOfAttachments is a variable of type map defined in your process
Let me know if you have any questions
thanks
girish
2 responses so far ↓
jdinnat // July 25, 2008 at 8:41 am |
Hi,
I try to use the execute script but I’m a little bit lost.
I have a process with a loop. I try to add a string into a list each time I enter in the loop.
here is my code :
—————————————————
import java.util.List;
import java.lang.String;
List loginListe = patExecContext.getProcessDataListValue(“/process_data/ListeNplusUn”);
String nplusun = patExecContext.getProcessDataValue(“/process_data/@nplusun”);
loginListe.add(“nplusun”);
patExecContext.setProcessDataListValue(“/process_data/ListeNplusUn”,loginListe);
———————————————-
The problem is a runtime error : “outofmemory “. If I take off the last instruction (the setProcessDataListValue) the error doesn’t appear and if there is no loop but the last instruction is present, there is no error.
I don’t know if it is the good place to ask my question. Sorry if it doesn’t.
jdinnat // July 25, 2008 at 8:58 am |
loginListe.add(”nplusun”); is replaced by loginListe.add(nplusun); of course