DYNAMICS 365 UPDATE RECORD OWNER AFTER ASSIGNREQUEST DEPRECATED

In a previous post, we saw how to change record status in Dynamics 365 using C# after the SetStateRequest message is deprecated.

In addition, when we wanted to update the owner of a record, we had to use the AssignRequest message to set it.

However, as you all know, the message AssignRequest is deprecated and in order to set the owner of a record, you can now use the Update request without doing another specific call.

In this post, we will see the function on how to change record owner in Dynamics 365 using C#.

  1. Below is the deprecated AssignRequest message used to set the owner of a record

    public void AccountAssignRequest(Account account)
    {
    var assignRequest = new AssignRequest
    {
    Assignee = new EntityReference(SystemUser.EntityLogicalName, new Guid("USERGUID")),
    Target = new EntityReference(Account.EntityLogicalName, account.Id)
    };
    AdminService.Execute(assignRequest);
    }

    Update record owner 1

  2. Currently, to set the owner of a record you can use the Update message as below

    public void AccountOwnerUpdate(Account account)
    {
    Account accountToUpdate = new Account
    {
    Id = account.Id,
    Name = "Account Owner set using Update message",
    OwnerId = new EntityReference(SystemUser.EntityLogicalName, new Guid("USERGUID")),
    };
    AdminService.Update(accountToUpdate);
    }

    Update record owner 2

Bonus Tip:
Don't forget to check and change the use of the AssignRequest in case you are migrating your environment.


Hope This Helps!

Comments

Popular posts from this blog

DYNAMICS 365 HOW TO HIDE RECENT RECORDS FOR LOOKUP FIELD IN UCI

SEARCH BY GUID IN DYNAMICS 365

SAVE FORM IN DYNAMICS 365 JAVASCRIPT