locked
Unable to close a letter activity. RRS feed

  • Question

  • Why does the following code (C#) not close a letter activity in CRM 4.0?

    Code Snippet
    activity.statuscode = new Status();
    activity.statuscode.Value = 4;
    activity.statecode = new LetterStateInfo();
    activity.statecode.Value = LetterState.Completed;

     

     

    I create a lead in the CRM, and then I assign a letter activity to it. Depending on specific scenarios I want to either add the new letter activity as open or add it as closed. I have tried all the following already:

     

    Action: Set status/statuscode of activity before creating the activity in the CRM
    Result: Defaults to Open


    Action: Create activity in CRM, fetch it, and then set status/statuscode followed by an update
    Result: Recieve the following error in the SoapException.Detail.InnerText -
                               0x80040216
                               an unexpected error occurred 
                               Platform

     

    Anything I do just doesnt seem to work....

     

    Anyone have any idea of why this isnt working?

     

    Cheers,

    James.

     

     

     

    Monday, January 12, 2009 1:37 PM

Answers

  • Resolved issue Smile

     

    All letter activities by default are created as "Open". However, there is a class type SetStateLetterActivity which can be used to change the status of the letter after it has been created.

     

    For anyone who has the same problem the following code should suffice:

     

    Code Snippet
    var request = new SetStateLetterRequest();
    request.EntityId = activityId;
    request.LetterState = LetterState.Completed;
    request.LetterStatus = 4;
    this.mainDataService.Execute(request);

     

    James.

     

    Monday, January 12, 2009 2:03 PM