Adding Objects to CollectionsThere are two methods enabling you to add object to a collection. ApiCollection.add(BO) This method allows you to add a particular business object to your user collection. ApiCollection.addAll(Collection) Appends or copies the whole Collection to another Collection. This way you can easily create sums of collections. All methods return BOOLEAN - TRUE if at least one object was added and FALSE if the collection has not changed. Example - Adding items to collections We assume that you have run Valuemation and logged in correctly before starting this code. oVM variable now holds Application object. See Login Syntax for the section of the opening code. Set oTransaction = oVM.createTransaction 'gets all BOs of Person type matching the criteria Set oPerson=oVM.getBOTypes.find("Person") Set oPersDept1= oPerson.createFilter(oTransaction,"departmentid=1") Set oPersDept2 =oPerson.createFilter(oTransaction,"departmentid=2") 'creates a new, empty BO Collection oJoinStaff=oVM.createCollection ‘fills this BO collection with values oJoinStaff.addAll(oPersDept1) oJoinStaff.addAll(oPersDept2) 'now we can work with a sum of employees from both departments ‘……. oTransaction.commit Comment: We might often want to create a list of persons belonging to various departments. First, a read only collection called “oPersDept1” is created by calling createFilter method. It returns all BObjects of BOType “Person” that come from department 1. Then, a similar collection of person coming from department 2 is created. Finally, an empty Collection “oJoinStaff” is created and both collections that are the output of createFilter are added. | |||||