---
schema_version: "1"
id: f085d37733a2e510c8b3f4309751f6ca216bc518c08231ffe8c9e8acecf300d8
title: RetrieveMscrmRecords()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/ampscript/references/microsoft-dynamics-crm/mc-ampscript-reference-microsoft-dynamics-crm-retrieve-records.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-mscrm/mc-ampscript-reference-microsoft-dynamics-crm-retrieve-records.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 33b182b984ed2ed267feae9293712aaf687aad747cf39f1d3996716de17f9c6a
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# RetrieveMscrmRecords()

Retrieves data from Microsoft Dynamics CRM entities.

## Availability

<table>
  <tr>
    <td>Marketing Cloud Engagement</td>
    <td>✅ Yes</td>
  </tr>
  <tr>
    <td>Marketing Cloud Next</td>
    <td>❌ No</td>
  </tr>
</table>

## Syntax

```
RetrieveMscrmRecords(entityName, fieldsToRetrieve,
                     queryFieldName, queryFieldOperator, queryFieldValue)
```

The `RetrieveMscrmRecords()` function has five parameters:

- `entityName` (string): Required. The name of the Microsoft Dynamics CRM entity to retrieve records from.
- `fieldsToRetrieve` (string): Required. A comma-separated list of fields to retrieve.
- `queryFieldName` (string): Required. The name of the field to filter on.
- `queryFieldOperator` (string): Required. The operator to use for the filter.
- `queryFieldValue` (string): Required. The value to filter on.

## Usage

This example retrieves the contact ID, first name, and last name for all contacts where the last name is Santos.

```
%%[
  Var @records_retrieved, @counter, @firstname, @lastname, @id
  Set @records_retrieved = RetrieveMscrmRecords("contact", "contactid,firstname,lastname",
                                                "lastname", "=", "Santos")
]%%

<p>Contacts:</p>
<br />

%%[
  For @counter = 1 to RowCount(@records_retrieved) do
  Set @firstname = Field(Row(@records_retrieved,@counter),'firstname')
  Set @lastname = Field(Row(@records_retrieved,@counter),'lastname')
  Set @id = Field(Row(@records_retrieved,@counter),'contactid')
]%%

<p>First: %%=v(@firstname)=%%</p>
<p>Last: %%=v(@lastname)=%%</p>
<p>Id: %%=v(@id)=%%</p>
<br />

%%[ Next @counter ]%%
```
