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 -
                               an unexpected error occurred 


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


    Anyone have any idea of why this isnt working?







    Monday, January 12, 2009 1:37 PM


  • 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;




    Monday, January 12, 2009 2:03 PM