def find_by_field(sobject, id, field_name)
      field_details = field_details(sobject, field_name)
      field_names = field_list(sobject).join(", ")

      if ["int", "currency", "double", "boolean", "percent"].include?(field_details[key_name(:type)])
        search_value = id
      else
        # default to quoted value
        search_value = "'#{id}'"
      end

      soql = "SELECT #{field_names} FROM #{sobject} WHERE #{field_name} = #{search_value}"
      result = query(soql)
      # Return first query result.
      result ? result.first : nil
    end
def find_by_field(sobject, id, field_name)
      field_details = field_details(sobject, field_name)
      field_names = field_list(sobject).join(", ")

      if ["int", "currency", "double", "boolean", "percent"].include?(field_details[key_name(:type)])
        search_value = id
      else
        # default to quoted value
        search_value = "'#{id}'"
      end

      soql = "SELECT #{field_names} FROM #{sobject} WHERE #{field_name} = #{search_value}"
      result = query(soql)
      # Return first query result.
      result ? result.first : nil
    end
Public: Finds a single record and returns all fields.

 sobject - The String name of the sobject.
 id      - The id of the record. If field is specified, id should be the id
           of the external field.
 field   - External ID field to use.

 Returns Hash of sobject record.