Microsoft Dynamics CRM Online 2016: Cannot set task/phonecall statecode to 'Completed' - dynamics-crm

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:
create a phone call entity with statecode=1 (Completed)
statuscode=2 (Made)
same idea with task (constants defined here)
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?

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.

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.

Related

Could not register pre-delete validatation plugin step for the Team entity in MS Dynamics CRM 2011

I want to add validation before Team entity deletion. In order to do that, I need to add Pre-validation plugin step for the Delete message and Team entity.
Nevertheless, when I'm trying to do it via the Plugin Registration Tool, I'm getting an error:
Invalid Entity Name
Invalid Primary Entity or Secondary Entity specified. Please re-enter the data.
Here is the data I'm filling in the Register New Step:
Message: Delete
Primary Entity: team
Secondary Entity: none
Run in User's Context: Calling User
Execution Order: 1
Eventing Pipeline Stage of Execution: Pre-validation
Execution Mode: Synchronous
Deployment: Server
I'm using Microsoft Dynamics CRM 2011.
I could not find any explanation for that. What I'm asking is:
What is the reason for that?
What is the intended way of applying custom validations during the deletion of the Team entity?
That's because Delete Message for Team Entity in CRM 2011 is not supported
Whereas when you look for CRM 2016 and above Team Entity does support delete Message
Summary: CRM 2011 Team Entity does not support Delete Message
It is possible to enable registering the plug-in by updating the corresponding SdkMessageFilterBase record.
Connect to your DB server.
Navigate to your %ORGANIZATION_NAME%_MSCRM DB.
Run the script:
SELECT
[dbo].[SdkMessageFilterBase].[PrimaryObjectTypeCode],
[dbo].[SdkMessageFilterBase].[CustomizationLevel],
[dbo].[SdkMessageFilterBase].[SecondaryObjectTypeCode],
[dbo].[SdkMessageFilterBase].[IsCustomProcessingStepAllowed],
[dbo].[SdkMessageFilterBase].[Availability],
[dbo].[SdkMessageFilterBase].[SdkMessageId],
[dbo].[SdkMessageFilterBase].[IsVisible]
FROM
[dbo].[SdkMessageFilterBase]
INNER JOIN [dbo].[SdkMessageBase]
ON [dbo].[SdkMessageFilterBase].[SdkMessageId] = [dbo].[SdkMessageBase].[SdkMessageId]
WHERE
[dbo].[SdkMessageBase].[Name] = 'Delete' AND
[dbo].[SdkMessageFilterBase].[PrimaryObjectTypeCode] = 9 -- Team entity code is 9
Check the result. If IsCustomProcessingStepAllowed field is set to 0, it is preventing you from registering the plug-in step.
Update IsCustomProcessingStepAllowed to 1 to be able to register custom plug-in step.
This solution worked for me.
Articles describing such solution:
Enabling plug-in for Change Business Unit and Change Manager for systemuser entity

How to create a WorkItem in Azure DevOps based off new email in Shared Inbox, but replies to emails stay within same task

I'm currently trying to set up a workflow within Microsoft Power Automate to do the following:
If an email is sent to a shared email box create a new task in DevOps
If someone replies back to that initial email - any responses to that thread will be tracked in the original task, and no additional tasks will be created from that chain.
Right now I'm leveraging the template that Microsoft provides called "Create a workitem in Azure DevOps when new email arrives in shared mailbox", but it creates additional tasks anytime someone replies back to the thread.
Anyone have suggestions?
Thanks,
You could use a condition that checks the 'Conversation Id' then if it matches an Id from a previously sent email's Conversation Id it does nothing. If it is new, then you'll get a new task.
If you are archiving handled emails, you'll need to filter results from the archival folder.
Here it is mapped out with a SharePoint list mapping the Conversation Id from each email:
Once the details are logged, the Get Items action on the SharePoint list pulls all items. However in that pull it uses an ODATA Filter on:
conversationId eq '<Conversation Id from trigger>'
Then if the number of matches is more than the one that you've just registered in the list, that means it was a response and the flow will follow the "no" branch. However, if it is the only entry, a new work item can be made.
You can make this much more complicated, dependent on requirements, in many areas, as that why you are using Power Automate. For example you could make API (Graph) calls to get Shared Box emails, but this is simpler, and works on a free flow plan until they add a "Get Emails from a Shared Mailbox" connector.
It's not picture perfect, because it doesn't handle a changed subject line, but it does do the job required.

Issue adding dynamic link in email template - CRM Dynamics 365

I have a process which triggers when a case is assign, the process send an email to the case owner with the content of the case which also include a dynamic link to the case assigned. I could achieve it in CRM 2011 however I don't see any option to insert dynamic link in CRM 365. Any help on this would be really appreciated.
Using template in workflow does not have this hyperlink option, but direct Email message will have.
Refer this community discussion for the different implementation ideas.
Dynamics CRM OOB does not support adding Record URL (Dynamic) to email template!
There is workaround, by adding a new custom field to the case entity, then create a workflow to fire on case create which updates the new field to be a Record URL (Dynamic), then simply add this field to your email template and attach the email template to your workflow

Dynamics CRM Web API - Assign Records / Update Owner field

I am trying to create a Task record in Dynamics 365 and I want the owner to be a team record for which I have already retrieved the GUID.
This is my JSON and it always fails.
{
"ownerid_team#odata.bind":"/teams(f7e383eb-3966-e711-8122-e0071b66c021)",
"scheduledend":"2017-07-20",
"regardingobjectid_new_survey#odata.bind":"new_surveies(f7e383eb-3966-e711-8122-e0071b84b034)",
"subject":"Amazon SES has suppressed sending to this address because it has a recent history of bouncing as an invalid address.",
}
I get a bad request.
Can we not use the Web API to update the owner field of records? I could not find any specific limitations describing the same.
Maybe try:
"ownerid#odata.bind":"/teams(f7e383eb-3966-e711-8122-e0071b66c021)",
Using Jason Lattimer's CRM REST Builder, I've gotten this to work:
entity["ownerid#odata.bind"] = "/teams(956B410F-0F6E-E711-810E-00155D6FD705)";
One thing to ensure is that the team has a valid security role. You might want to try assigning the team in the UI to make sure the operation works before trying to do it programmatically.

Callbacks from MS Dynamics CRM to a webservice

We're building a system that is tightly integrated with a clients CRM install, and need to have a callback fired when an entity is updated, created or deleted. This callback will ideally send the entity name and id to an external service via a HTTP get request.
I've not found any docs online that help - can anyone point me in the right direction?
You're looking for plugins: http://msdn.microsoft.com/en-us/library/dd393295.aspx.
You can register a plugin on Create, Update, Delete, etc. of an entity, and then run any custom code you'd like. You'll definitely have access to the entity name and the id, as well as fields that were updated, information on the user who initiated the call, etc.
Just know that in MSCRM 3.0 & 4.0, plugins run outside the actual database transaction, so it's possible the event could fire in CRM, but the plugin fails and the event still goes through. In MSCRM 2011, they run inside the transaction, and can stop the CRM event from happening if need be.

Resources