def reply(workitem)
      update_tree
      # If we have a where clause at all...
      if translated_where = attribute(:where, nil, :escape => true)
        if translated_where.to_s == 'entities_match'
          # Check to see that the event's entity is equal to the current workitem's
          # entity.  If so, this message is intended for us.
          translated_where = '${"f:entity_id} == ${"f:receiver.entity_id} && ${"f:entity_type} == ${"f:receiver.entity_type}'
        else
          # This just gives us a shortcut so the process definition reads more
          # clearly.  You could always use "${f:" and "${f:receiver." in your
          # where clauses, but you have to remember that the former refers to the
          # incoming event's workitem, and the latter is the workitem of the
          # listening process.
          translated_where.gsub!(/\$\{(['"]?)event:/, '${\1f:') # event workitem
          translated_where.gsub!(/\$\{(['"]?)this:/, '${\1f:receiver.') # listening workitem
        end
        h.updated_tree[1]['where'] = translated_where
      end
      workitem['fields']['receiver'] = h.applied_workitem['fields']
      super
    end
def reply(workitem)
      update_tree
      # If we have a where clause at all...
      if translated_where = attribute(:where, nil, :escape => true)
        if translated_where.to_s == 'entities_match'
          # Check to see that the event's entity is equal to the current workitem's
          # entity.  If so, this message is intended for us.
          translated_where = '${"f:entity_id} == ${"f:receiver.entity_id} && ${"f:entity_type} == ${"f:receiver.entity_type}'
        else
          # This just gives us a shortcut so the process definition reads more
          # clearly.  You could always use "${f:" and "${f:receiver." in your
          # where clauses, but you have to remember that the former refers to the
          # incoming event's workitem, and the latter is the workitem of the
          # listening process.
          translated_where.gsub!(/\$\{(['"]?)event:/, '${\1f:') # event workitem
          translated_where.gsub!(/\$\{(['"]?)this:/, '${\1f:receiver.') # listening workitem
        end
        h.updated_tree[1]['where'] = translated_where
      end
      workitem['fields']['receiver'] = h.applied_workitem['fields']
      super
    end
On apply, the workitem for this FlowExpression was replaced by the workitem
 from the event.  So when we refer to "f:" in this #reply method, we're
 looking at the event's workitem, which will be discarded at the end of this
 reply (and replaced with the applied workitem).  In order to compare the
 event's workitem with the applied workitem (so we can determine whether or
 not the event was intended for us), we assign the applied_workitem's fields
 to a hash on the event's workitem fields, available at "f:receiver.*".