We are trying to change the owner of an entity record using UpdateRequest message with the corresponding entity record. This happens only while changing any entity record owner from a team to a user.
For e.g. If there is an existing entity record Record1 with OwnerId as Team1 then we are trying to perform the following:
But if we try to change the owner again from user1 to user2 then we are getting the below error from CRM.
"team With Id = user1 Does Not Exist"
This happens only when we try to change the owner to the user (User1) using the same user's (User1) credentials but if we try to change the owner using the other user's (User2) credentials then it's working. But this is not issue with change the owner to User2 using User2 credentials.
Also everything works fine if we create an entity reference instance with Id as user1 and LogicalName as "systemuser" instead of "" for OwnerId attribute.
Could anyone please help me out finding the below.
*This post is locked for comments
Don't forget to verify helpul answers as replies.
Yes it's really weird and thanks for significant suggestions. We have fixed it by passing the appropriate LogicalName as of now anyway.
Hi,
Actually it's weird.
Maybe your user1 and team1 is same Identity (GUID) in database (normally there is no chance for this but maybe about integration fault etc), you should check that.
On the other hand, normally you should give "logicalname" for EntityReference, I think when you don't set this name in your code (new EntityReference("", assigneeId)), OwnerId changed but "OwnerIdType" code still protect its value (team = 9), and when you try assign again OwnerId and OwnerIdType code not matched.
I recommend below;
- Firstly monitor your database process (Sql Profiler) with your current code (new EntityReference("", assigneeId)) and check what happens in SQL commands
- Change your code with entity logicalname and check again.
- Last but important note you should use logicalname in EntityReference ;)
No Emre. It's as below and hence the mentioned behavior. But it works as expected if we create an EntityReference instance with systemuser as LogicalName as mentioned by you and a33ik.
Entity entity = new Entity(targetEntityLogicalName.Trim()); entity.Id = targetId; entity["ownerid"] = new EntityReference("", assigneeId);]
Hi,
Is your code same with this;
Entity entity = new Entity(targetEntityLogicalName.Trim()); entity.Id = targetId; entity["ownerid"] = new EntityReference("systemuser", assigneeId);
Hello,
I have no idea. It's mostly platform thing so nobody except Microsoft (who has an access to sourcecode) has an answer.
Hi Andrii,
Thanks for the quick reply. Yes, we tried that and it worked without any issues. But just would like to understand why is it happening for User1 but not User2 inspite of User1 is having System Administrator role.
Hello,
Is there any chance you can populate LogicalName with "systemuser" value? That should resolve your issue.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156