Updating statecode of Activitypointer using SQL - CRM 4.0 RRS feed

  • Question

  • I'm trying to update the statecode of a number of ActivityPointer records. They are currently set to open, but need to be set to 'Completed'. I was thinking of doing this via directly changing the database using SQL. I tried it for one record, and while it changed the Activity status to 'Completed', I then got an error saying that 'length' couldn't be defined. So I'm presuming that there needs to be some sort of start & end times filled in and length is probably calculated from those times. However, the fields on the Activity are read only (as is the status, that's why I'm trying to update them directly in the database). I don't know muc about Activitypointer, so I'm presuming it's a 'special' entity? There's no form associated with it.

    The reason I'm trying to update these records, is because the users want them closed off so they can close the associated communications. Maybe it's not possible/advisable to do this though?


    Tuesday, December 3, 2013 12:09 PM


  • Hi, 

    You shouldn't update the database via SQL directly since this will circumvent all the business logic and it is very difficult to ensure that the update is the same as it would be through the SDK. Because this, it is likely you will run into issues that will not be supported by Microsoft.

    I would recommend that you use the SDK to update the activities using code along the lines of:

    SetStateTaskRequest state = new SetStateTaskRequest();
    state.EntityId = activityid;
    state.TaskState = TaskState.Completed;
    state.TaskStatus = -1;
    SetStateTaskResponse stateSet = (SetStateTaskResponse)service.Execute(state);

    See more about the SDK here - http://msdn.microsoft.com/en-gb/library/bb887829.aspx

    Hope this helps,


    Scott Durow
    Blog www.develop1.net    Follow Me
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Tuesday, December 3, 2013 1:19 PM