Inserting a Related Object Accessor or Related Collection Accessor Field Name

As shown in the figure below, to insert the name of an Related Object or Related Collection field, select the object and field in the express ion palette, and click (Insert) as you do with any other type of field.

  1. Select the Trouble Ticket node in the tree (representing the current object in this example)

  2. Select the desired Related Collection or Related Object field in the table at the right, for example, the ActivityCollection_c field.

  3. Click the (Insert) button.


Selecting a Field from an Object in a Related Collection

Once you have inserted the name of the related collection field, you can write a loop to process each row in the collection like this:

def activities = ActivityCollection_c
while (activities.hasNext()) {
  def activity = activities.next()
  // if the activity status is 'Open'...
  if (activity.Status_c == 'Open') {
    // do something here to the current child activity
  }
}

When writing the code in the loop that processes Activity rows, you can use the Expression Palette again to insert field names of the object in that collection by selecting the Activities collection in the tree, choosing the desired field, then clicking (Insert).