Answered by:
account.ownerid is not getting updated

Question
-
Hi,
The following code used to work in CRM 3.0. After we did upgrade to 4.0 it is not working.
CRMService.
account actrecord = (CRMService.account)queryresults.BusinessEntities[0]; //update owneridactrecord.ownerid =
new Owner();actrecord.ownerid.type =
EntityName.systemuser.ToString();actrecord.ownerid.Value =
new Guid("2e08b59a-9abf-da11-b95d-001422b1f1b8");crmsvc.Update(actrecord);
I greatly appreciate any help.
thank you
hanu
Monday, December 22, 2008 6:21 PM
Answers
-
You should use the assign message instead of the update message.
// Create the SecurityPrincipal object.
SecurityPrincipal assignee = new SecurityPrincipal();
assignee.Type = SecurityPrincipalType.User;
// PrincipalId is some known Guid belonging to the user or team that will own this record.
assignee.PrincipalId = new Guid("2e08b59a-9abf-da11-b95d-001422b1f1b8");
// Create the target object for the request.
TargetOwnedAccount target = new TargetOwnedAccount();
// Set the properties of the target object.
// EntityId is some known Guid belonging to the account that is being assigned to the user.
target.EntityId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");
// Create the request object.
AssignRequest assign = new AssignRequest();
// Set the properties of the request object.
assign.Assignee = assignee;
assign.Target = target;
// Execute the request.
AssignResponse assignResponse = (AssignResponse)service.Execute(assign);- Marked as answer by DavidJennawayMVP, Moderator Saturday, May 16, 2009 8:43 PM
Tuesday, December 23, 2008 11:59 PMModerator
All replies
-
Tuesday, December 23, 2008 9:44 PM
-
You should use the assign message instead of the update message.
// Create the SecurityPrincipal object.
SecurityPrincipal assignee = new SecurityPrincipal();
assignee.Type = SecurityPrincipalType.User;
// PrincipalId is some known Guid belonging to the user or team that will own this record.
assignee.PrincipalId = new Guid("2e08b59a-9abf-da11-b95d-001422b1f1b8");
// Create the target object for the request.
TargetOwnedAccount target = new TargetOwnedAccount();
// Set the properties of the target object.
// EntityId is some known Guid belonging to the account that is being assigned to the user.
target.EntityId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");
// Create the request object.
AssignRequest assign = new AssignRequest();
// Set the properties of the request object.
assign.Assignee = assignee;
assign.Target = target;
// Execute the request.
AssignResponse assignResponse = (AssignResponse)service.Execute(assign);- Marked as answer by DavidJennawayMVP, Moderator Saturday, May 16, 2009 8:43 PM
Tuesday, December 23, 2008 11:59 PMModerator -
Hi,
Update those lines which is in blue color.
CRMService.account actrecord = (CRMService.account)queryresults.BusinessEntities[0];
//update ownerid
actrecord.ownerid = new Owner();
actrecord.ownerid.type = EntityName.systemuser.ToString();
actrecord.ownerid.Value = new Guid("2e08b59a-9abf-da11-b95d-001422b1f1b8");
//Update particular accountid for a accout that you wanted to update.
actrecord.accountid = new Key();
actrecord.accountid.value = "Give the account id"
crmsvc.Update(actrecord);
Regards,
Natarajan G.
Thursday, December 25, 2008 8:41 AM