---
schema_version: "1"
id: 08befbd42ddefd0039b884429016f98f6a87a3b9adf3e927d8d3add2d9605211
title: SetStateMscrmRecord()
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-set-state-record.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-mscrm/mc-ampscript-reference-microsoft-dynamics-crm-set-state-record.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 8a41e851437bef627ea7b66fa11b29d8eb8f61aa2df6bcf0cc2ebc661ddf3647
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# SetStateMscrmRecord()

Sets the state and status of a Microsoft Dynamics CRM record.

**note:** Some entities, including Opportunity, require special CRM requests to change their state. This function doesn’t work for those 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

```
SetStateMscrmRecord(recordGuid, entityName,
                    stateToSet, statusToSet)
```

The `SetStateMscrmRecord()` function has four parameters:

- `recordGuid` (string): Required. The GUID of the record to set the state and status of.
- `entityName` (string): Required. The name of the Microsoft Dynamics CRM entity.
- `stateToSet` (string): Required. The state to set for the record. Accepted values: `active` or `inactive`.
- `statusToSet` (string): Required. The status to set for the record. Accepted values: `0`, `1`, or `-1`. A value of `-1` resets the status to its default value.

## Usage

This example changes the state of an account to inactive.

<!-- The GUIDs used in this example are randomly generated and do not represent a security risk. -->

```
%%[
  SetStateMscrmRecord("679ab01a-e998-4e4f-b5e6-a49bcef99c76", "account", "Inactive", "-1")
]%%
```

The function doesn’t return a value.
