locked
account update error through crm sdk? RRS feed

  • Question

  • Hello - I'm trying to make an Account update through the SDK using the Organization.svc. Here are a few lines of key code:

    entity = serviceProxy.Retrieve("account", accountId, columnSet);
    entity["ownerid"] = new EntityReference("ownerid", new Guid("A8AA28B4-9015-DF11-8062-000E0CA08051"));
    serviceProxy.Update(entity);

    I can retrieve the account without issue. However, I need to update the OwnerId which I'm attempting to do in the code above. The attempted update returns the following error:

    "The value of 'new_action' on record of type 'account' is outside the valid range."

    What am I missing here?

     

    Friday, May 24, 2013 11:43 PM

Answers

  • If you want to change the owner of a record you need to use an AssignRequest.
    Guid accountId = new Guid("90F8889F-EB95-E781-8417-000C44420CBC");
    Guid newOwnerId = new Guid("A8AA28B4-9015-DF11-8062-000E0CA08051");
    AssignRequest assignRequest = new AssignRequest
            {
                Assignee = new EntityReference("systemuser", newOwnerId),
                Target = new EntityReference("account", accountId)
            };
    serviceProxy.Execute(assignRequest);


    My blog: www.crmanswers.net

    Friday, May 24, 2013 11:59 PM

All replies

  • If you want to change the owner of a record you need to use an AssignRequest.
    Guid accountId = new Guid("90F8889F-EB95-E781-8417-000C44420CBC");
    Guid newOwnerId = new Guid("A8AA28B4-9015-DF11-8062-000E0CA08051");
    AssignRequest assignRequest = new AssignRequest
            {
                Assignee = new EntityReference("systemuser", newOwnerId),
                Target = new EntityReference("account", accountId)
            };
    serviceProxy.Execute(assignRequest);


    My blog: www.crmanswers.net

    Friday, May 24, 2013 11:59 PM
  • Guid accountId = new Guid("90F8889F-EB95-E781-8417-000C44420CBC");
    Guid newOwnerId = new Guid("A8AA28B4-9015-DF11-8062-000E0CA08051");
    AssignRequest assignRequest = new AssignRequest
            {
                Assignee = new EntityReference("systemuser", newOwnerId),
                Target = new EntityReference("account", accountId)
            };
    serviceProxy.Execute(assignRequest);

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Yogesh Vijay Mulay

    Monday, May 27, 2013 10:38 AM