VLOOKUP_ALL

Description

Queries the specified object and returns the designated fields (plus the record Id and lookup field) from all records that match one or more field-value pairs, with an optional additional filtering clause.

Syntax

VLOOKUP_ALL(target_object_name, return_field_names, ...[matching_field_name, matching_field_value], additional_clause_optional) -> List<Map<String, ANY>>

Parameters

ParameterData TypeRequiredDescription
target_object_nameStringYesThe API name of the object to query.
return_field_namesStringYesA comma-separated string of field API names to return from each matching record.
…matching_field_nameStringYesThe name of the field used to match records.
…matching_field_valueObjectYesThe field value used as matching criteria.
additional_clause_optionalStringNoAdditional SOQL criteria for restricting or ordering the matching results.

Example

VLOOKUP_ALL("Opportunity", 
            "Name, Amount", 
            "AccountId", Id)
-- Returns the Name and Amount from every Opportunity where AccountId matches the current record's Id. 
-- Each record also includes Id and the lookup field (AccountId).

Tips

  • SOQL queries have a governor limit of 50,000 rows per transaction. Because VLOOKUP_ALL returns every matching record, refine your matching criteria or additional_clause_optional to keep the result set within this limit.