# Entity Ownership, User Mapping

Most entities in Dynamics CRM have an Owner, which is specified by the ownerid field.

The owner is normally a systemuser, but may also be the Organization or a Business Unit. For example, an account or contact is normally owned by a systemuser, but a product is normally owned by the Organization.

When you create a connector to Dynamics CRM, you specify a user to log in with. When you use Inaportto create an entity such as account or contact, by default the entity will be owned by the login user.

You can override this default in two ways:

1. Use the msSetOwner() function. This will change the default user for creation to the mapped user. You need to provide a User ID to the function.
2. Map a valid user ID to the virtual field "vf_AssignOwner", which is provided byInaport on any entity that has an ownerid field.

You can obtain a valid user ID in two ways:

1. Use the User Map to establish a map between the users in a source CRM system to the Dynamics CRM users, then use the function usermap() to retrieve the ID of a mapped user.
2. Use the msGetUserID() function to retrieve the ID of a named user.

The combination of these approaches allows you to:

1. Set a default owner and use it always.
2. Change the default owner for all entities i response to the imported data
3. Change the owner only for specific entities.

## Important Note

When an entity is created in Dynamics CRM, it is always owned by the authenticated user (i.e. the user specified for log in). If you use any of the approaches above to change the ownership, Inaportwill change the ownership of the entity after it has been created.

This means that after the entity is created, a second call is made to Dynamics CRM to change the ownership. This may have performance implications if you need to do it on many records. The best approach is to set the login user to be the owner for the bulk of the records being imported, if possible.