Skip to content

Commit 2448997

Browse files
authored
Update define-custom-state-model-transitions.md
Add Important note about behaviors of update statecode without statuscode
1 parent baf29fc commit 2448997

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

powerapps-docs/developer/data-platform/define-custom-state-model-transitions.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,17 @@ Tables that support the concept of state have a pair of columns that capture thi
3636
|------------------|------------------|-----------------|
3737
|`statecode`|**Status**|Represents the state of the record. For custom tables this is **Active** or **Inactive**. You can't add more state choices but you can change the choice labels.|
3838
|`statuscode`|**Status Reason**|Represents a status that is linked to a specific state. Each state must have at least one possible status. You can add additional status choices and change the labels of existing choices.|
39-
39+
40+
> [!NOTE]
41+
> It is important to always pair `statecode` with the desired `statuscode` in update operations. When the `statecode` is updated without specifying a `statuscode`, the first `statuscode` item configured in the list of statuscodes will be used.
42+
> For example, assume a case record has a statuscode of 2 (On Hold). After running the code below, the statuscode will be updated to 1 even if it wasn't specified in the update operation.
43+
> ```csharp
44+
> var row = new Entity("incident", new Guid("ac1f2a46-6351-44f0-b42f-a478a2bb6e06"));
45+
> row["statecode"] = 0; //active
46+
> organizationService.Update(row);
47+
> ```
48+
> Furthermore, if auditing is enabled in the environment, on the table and on the `statuscode` column, there will be no audit logs of the example above since the actual update statement had no `statuscode` specified.
49+
4050
The table definitions for the columns defines what status values are valid for a given state. For example, for the `Incident` (**Case**) table, the default state and status options are shown in the following table.
4151
4252
|State|Status|
@@ -82,4 +92,4 @@ When this data is present and the table `EnforceStateTransitions` property is `t
8292
[Define status reason transitions](/powerapps/maker/data-platform/define-status-reason-transitions)<br />
8393
8494
85-
[!INCLUDE[footer-include](../../includes/footer-banner.md)]
95+
[!INCLUDE[footer-include](../../includes/footer-banner.md)]

0 commit comments

Comments
 (0)