Tip #1441: Owner is a user is a team

WARNING: Niche L400 tip ahead.

tl;dr

If you’re expect primary column name to be tablename + “id“, add an exception for systemuser and team tables – both will come back as ownerid in custom API.

L400

If custom API has an output property of type EntityReference then, for example, for account (or any other “normal”) table, the following json is returned as expected:

"Account": {
   "@odata.type": "#Microsoft.Dynamics.CRM.account",
   "accountid": "87aa5cfb-197c-ea11-a813-000d3abeef18"
 }

Save yourself a trip to metadata and use tablename + “id” for the primary column name, right? Not so fast. For either systemuser or team, you get ownerid instead of expected systemuserid or teamid

"User": {
   "@odata.type": "#Microsoft.Dynamics.CRM.systemuser",
   "ownerid": "889362cfb-22aa-eaea-abba-dead3a6a9942"
}

No one knows dev docs better than Jim Daly, his patience to express RTFM sentiment is fascinating.

In Web API ownerid is the primary key for the systemuser EntityType and the team Entitytype because both inherit this property from the principal EntityType, which enables the capability for either type to be owners of records.

— Jim Daly

The ownerid value is the same as the respective systemuserid or teamid columns.

EDIT: the same applies to any activity table, e.g. task, email, appointment, etc, because any table that is configured as an activity inherits from the activitypointer entity type. The primary key for any activity will be activityid, according to Web API EntityTypes – Power Apps | Microsoft Learn.

4 thoughts on “Tip #1441: Owner is a user is a team

  1. Natraj says:

    Isn’t this misleading though a systemuser lookup can be used in other scenarios? e.g. assigned to

  2. _neronotte says:

    > If you’re expect primary column name to be tablename + “id“, add an exception for systemuser and team tables

    Also for all the activity tables (task, email, appointment, …). The primary column is “activityid”

Leave a Reply

Your email address will not be published. Required fields are marked *