Dynamics CRM Web API - Assign Records / Update Owner field - asp.net-web-api

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.

Related

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.

Is it possible to update a group's auto-reply settings using the API?

I'm using Gmail.Users.Settings.updateVacation to update our customer service rep's vacation responses automatically over the weekend and after-hours, so our customers who e-mail when we're not in the office get an informative message of when they can expect a response.
I am attempting to do the same thing with our Google Groups, but have not been able to find the correct API call. If I use the same method as above, but with a group's e-mail address, I get a "Delegation denied" error (even though I'm an Owner of the group). I suspect this is because a Group is not a User, and is just different.
I've found the Manage Group Settings API, which essentially has just one update method, and you use properties to specify what you want to update on the group. The problem is, there is no auto-reply property name that I can find.
How do I update a Group's auto-reply settings?
Many thanks!
Unfortunately, what you want cannot be achieved through the API.
All the possible methods are present in the Groups Settings API so if you didn't find the expected method there, then it means that is not possible through the API.
What you can do instead is to file a Feature Request here and provide all the necessary details.
Reference
Groups Settings API - Groups Resource.

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

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.

Addressing the customer by their first name in CRM 2011 email templates triggered by Service Activity workflows

If a customer schedules a service activity using my web application and I want to send them an automated confirmation email, it seems I have two options:
Have the workflow create and send a new email message. On this view (see below), you can use fields from related entities on the service activity (e.g. the customer's first name).
Have the workflow use an email template. It seems that email templates do not allow you to access fields from a related entity, like first name, so the only option here is to address the customer by their FULL name.
Are there any solutions that I missed, or am I stuck with the first option if I want to address the customer in a personal, natural way on this automated email?
Unfortunatly, the CRM is pretty limited on that aspect. The best workaround is to add the firstname to the Service Activity entity. May suit you or not. Otherwise, it is achievable through a the SDK, but that's much more complicated if you don't already use it.

Can an arbitrary email address be used in workflow send email activity

I'm wondering if there is any way to be able to include an arbitrary email address as the To:, From:, CC: or BCC: fields of a send email activity? It appears that they must be contacts in the CRM.
I ask this because I have a requirement to cc a known group email (no actual user associated with the email...something like support#mycompany.com...though it's not a queue at all). I'm concerned that if I create a CRM user for this email, that when I move to production, I'll have to change all the workflows using this email to point to the CRM entity on the production box (assuming GUID is saved with activity).
If an arbitrary email isn't possible, any other suggestions?
I'm not quite sure, if I have unterstood your question right:
You want to create a workflow which contains a send mail activity. You would like to set one of the address fields (To:, From:, CC:) to a plain mail address like 'foo#bar.org'?
It is possible if
you enter the mail address by hand (do not use the field assistant)
you have configured that e-mails with unresolved recipients are allowed to be sent.
See Settings -> Administration -> System Settings -> E-Mail Tab
you don't want to set the e-mail address with another workflow step
To my knowledge, the only way to do this would be to create a custom workflow assembly. This may be more trouble to you than it's worth.
I doubt it. Not without horrible SDK or Custom Workflow Activity machinations, which even then may not work. Unless you have a truly gargantuan number of workflows that must be altered, the manual approach may be the best.
It may be a terrible hack, but you might be able to replace instances of the development environment support account GUID with its production counterpart directly in SQL Server. Not in the SystemUserBase table, but in whatever workflow activities mention the support account as a CC field in an e-mail. But that is scary stuff.
You may also want to take another look at your process; a significant portion of Dynamics CRM is dedicated to handling support issues, and that includes fairly robust e-mail tracking and storage; there probably shouldn't be a need to CC this support mailbox to which you refer.
In summary: All of the options I've listed are terrible. Find a way to avoid them. :-P
I've had this requirement before, and even with workflow activities, there doesn't seem to be a way to handle this (even though CRM will allow it through the UI).
Your instinct is right that if you create a user separately in both environments and then try to move a workflow that references that user between the environments, that the workflow references will have to be updated.
The best solution, to me, would be to go with just creating the contact/user in one environment. But then, create the contact/user in your other environments with the same Guid. You can do this through the API quite easily, or for a no-code solution, there is a Microsoft provided CRM Configuration Data Utility (http://msdn.microsoft.com/en-us/library/dd442453.aspx) that you can use. (Note that the utility will want to migrate all records from the chosen entity, so you might want to export it to a file, edit the resulting file which is just XML, and then import to your target).
This is something that you can do with CRM 2011, CRM 2013, or CRM 2015 if you have a custom entity that is email enabled and then copy the email address from your core entity even if that email address is in a custom text field to it and relate it back via a lookup field. Doing that would require a plugin in Microsoft CRM 2011, but is possible to do with real-time workflows in Microsoft CRM 2013 and Microsoft CRM 2015. This method would allow you to have email addresses associated to the records and available for usage with the CRM workflows to send emails without needing to create an additional user or contact record. This is also handy if you are working with an entity like Incidents that is a core CRM entity and is not email enabled, yet you wish to be able to send emails related to that entity. You could use this method in conjunction with the steps ccellar provided.
I've got a blog post that goes through an example of this here: http://dynamicsuniversity.com/steps-to-send-emails-to-custom-email-address-text-field-from-a-workflow/
You can write custom workflow or you should go for plugin development.
You will get details for it on below blogs.
For custom-workflow
https://msdn.microsoft.com/en-us/library/gg334455.aspx
Blog:-
https://lakshmanindian.wordpress.com/2012/10/14/custom-workflow-activity-in-microsoft-dynamics-crm-2011/
more knowledge on your email sending requirement.
https://social.microsoft.com/Forums/en-US/375f5dad-0382-4112-ab0d-5b42ba235d96/crm-2011-workflow-sending-email-problem?forum=crmdevelopment

Resources