Wednesday, July 25, 2012 6:55 PM
How do I set the owner of a record that I'm creating in a console app? Do I use CrmEntityReference?
:Guid OWNERID = (Guid)myReader["owner"]; //GUID returned from SQL SP dataset
var CONTACT = new Contact()
//set Contact fields here
CONTACT.OwnerId = new Microsoft.Xrm.Client.CrmEntityReference("SystemUser", OWNERID);
Wednesday, July 25, 2012 7:42 PM
You need to use the AssignRequest, see MSDN http://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.assignrequest.aspx with something like this...
// Create the Request Object and Set the Request Object's Properties
AssignRequest assign = new AssignRequest
Assignee = new EntityReference(SystemUser.EntityLogicalName, _otherUserId),
Target = new EntityReference(Account.EntityLogicalName, _accountId)
// Execute the Request
// where _service is the OrganizationServiceProxy
You can get examples for these in the SDK documentation @ http://www.microsoft.com/en-us/download/details.aspx?id=24004
Thursday, July 26, 2012 4:37 AMso when you are creating a record you cannot set the owner?
Thursday, July 26, 2012 3:53 PM
Found the answer (not from copying MS SDK websites)
Guid OWNERID = (Guid)myReader["owner"];
OwnerId = new Microsoft.Xrm.Client.CrmEntityReference(SystemUser.EntityLogicalName,OWNERID)
- Marked As Answer by David Withers Thursday, July 26, 2012 3:53 PM