Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 421101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:57:01+00:00 2026-05-12T18:57:01+00:00

I’m trying to work out how to use the CrmService to close a Task

  • 0

I’m trying to work out how to use the CrmService to close a Task in MS CRM 4.0

I’ve tried to use the SetStateTaskRequest to set a Task’s state and status to TaskState.Completed and 5. I also tried TaskState.Completed and -1, but no dice there either.

Either way, I only receive the ever-helpful "Server was unable to process request" exception on the CrmService.Execute attempt.

I can create and update Tasks as freely as I please. But I can’t seem to set them to completed. It’s frustrating.

I noticed that I can only set the state of a Task to Completed in CRM through the Close Task action. I was wondering if there is a separate CrmService call that I need to make to perform the Close Task action, rather than going through the CrmService.Execute method.

Oh: I’m logging into the CrmService with full permissions. So I can’t see that it would be a permissions issue on the task item.

I can’t think what else could be causing this issue. Any advice or even just a point in the right direction would be very much appreciated.

FIRST EDIT:

Thanks to grega g‘s answer for getting me to check the Detail field of the exception.

I now have a more detailed exception message. In XML Form:

<error>
    <code>0x80040203</code>
    <description>Invalid format of input XML for request SetStateTask: required field 'EntityId' is missing.</description>
    <type>Platform</type>
</error>

Which is bizarre – consider my code (almost identical to greg g’s:

SetStateTaskRequest request = new SetStateTaskRequest();
request.EntityID = gTaskId;
request.TaskState = TaskState.Completed;

// ETaskStatusCode is an enumeration of the status codes taken from the StringMap in CRM.
//
// ETaskStatusCode.Completed = 5 - I can confirm this is the accurate status value for a Closed Task.
//
// Also, I have attempted this code with -1, which the documentation claims should cause the status
// to automatically be set to the default status for the supplied state. No change there.
request.TaskStatus = (int)ETaskStatusCode.Completed;            

SetStateTaskResponse response = CRMManager.CrmService.Execute(request) as SetStateTaskResponse;

Also, just to confirm that I have the right status code (and also share something I’ve found very useful when dealing with MS CRM), here’s the SQL I use to determine the values for entity statuses.

SELECT
    MSE.ObjectTypeCode,
    MSE.PhysicalName,
    SM.AttributeName,
    SM.Value,
    SM.AttributeValue
FROM MetadataSchema.Entity MSE
    INNER JOIN StringMap SM on MSE.ObjectTypeCode = SM.ObjectTypeCode
ORDER BY MSE.PhysicalName, SM.AttributeName, SM.AttributeValue  

I can confirm from the MS CRM web interface that the Status value that is associated with a Completed task is also named Completed. I can confirm from the SQL above that the value of this status, for a Task, is 5 – this is the value passed in from my Enum.

I can also confirm that gTaskId is being set to a valid Guid that references a Task that actually does exist, and is open at the time the close is attempted.

Curiouser and curiouser. Any thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:57:01+00:00Added an answer on May 12, 2026 at 6:57 pm

    Found it!

    Okay – reviewing my code above and the error message closely, my CrmService contained the property EntityID – but the exception was that the property EntityId was missing.

    Somehow, my CrmService had its EntityId property renamed to EntityID.

    Renaming the property fixed the problem. I still have no idea how that happened in the first place.

    To be safe, I’ll regenerate a new Service proxy to make sure that my properties are correctly named.

    Looking through the code, it seems that someone did a find-and-replace on ‘Id’ and turned it into ‘ID’ – which incidentally is the naming convention in my workplace for Property fields that represent primary keys.

    Thanks again to grega g for pointing out that the Detail property had the extra information I needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.