1
votes

When using the Microsoft Dynamics CRM Online 2016 OData API, I ran into a problem creating a task/phonecall with statecode equal to completed.

Problem Description:

  1. create a phone call entity with statecode=1 (Completed) statuscode=2 (Made) same idea with task (constants defined here)

  2. API returns an internal server error saying that:

2 is not a valid status code for state code PhoneCallState.Open on phonecall with Id cfdb5757-3666-e611-80fa-3863bb2ed1f8.

Dynamics server ignored the PhoneCallState.Completed (statecode = 1) parameter that I passed to it. For now, the workaround is to make a separate PATCH request to update the statecode and statuscode.

Is there a way to create a task/phonecall with completed state in one request?

2
It would help if you posted your code.James Wood
It would have been nice if the api allowed this statecode to be set on POSTjbooker

2 Answers

1
votes

I don't believe you can create a record in a completed status (statecode). So you will need to do a create call followed by an update or set state, I think that is just the way CRM works.

1
votes

I believe that James's answer is correct. If you truly wanted to perform a single create, and create it as Completed, you could add two new fields to the Entity (PostCreateStatus, PostCreateState) and then create a Post Create Plugin that updates the status and state. This would be result in a single call to the server, creating the entity with the desired states and statuses.