# File lib/ruote/exp/fe_filter.rb, line 528
    def apply

      h.applied_workitem['fields'].delete('__result__')
        #
        # get rid of __result__

      filter =
        referenced_filter || complete_filter || one_line_filter || block_filter

      record = filter.first.delete('record') rescue nil
      flush = filter.first.delete('flush') rescue nil

      record = '__validation_errors__' if record == true

      opts = {
        :double_tilde => parent_id ?
          (parent.h.applied_workitem['fields'] rescue nil) : nil,
        :no_raise => record
      }
        #
        # parent_fields are placed in the ^^ available to the filter

      fields = Ruote.filter(filter, h.applied_workitem['fields'], opts)

      if record and fields.is_a?(Array)
        #
        # validation failed, :record requested, list deviations in
        # the given field name

        (flush ?
          h.applied_workitem['fields'][record] = [] :
          h.applied_workitem['fields'][record] ||= []
        ).concat(fields)

        reply_to_parent(h.applied_workitem)

      else
        #
        # filtering successful

        reply_to_parent(h.applied_workitem.merge('fields' => fields))
      end
    end