// Assume code in context of TroubleTicket
// define a variable to hold activities collection
def activities = ActivityCollection_c
// work with activities here...
|
|
---|---|
|
|
|
|
|
|
|
|
// store the child row iterator in a local variable
def activities = ActivityCollection_c
// ensure iterator is on slot before first row
activities.reset()
// loop while there are more rows to process
while (activities.hasNext()) {
// access the next row in the row iterator
def curActivity = activities.next()
// reference fields or object functions from the current row
if (curActivity.Status_c == 'Open') {
// do something here to the current child activity
}
}
// to process the same row iterator again in this block of code,
// call activities.reset() method again to reset the
// iterator to the slot before the first row
def activities = ActivityCollection_c
// If there are no child activities...
if (activities.first() == null) {
// Do something here because there are no child activities
}
else {
// There are some child activities, call reset() to set
// iterator back to slot before first row
activities.reset()
while (activities.hasNext()) {
def curActivity = activities.next();
// Do something here with the current activity
}
}