Specific record retrieval in Virtual Entity Dynamics 365 - dynamics-crm

I tried to set up virtual entity and yes I am able to show the record in CRM. But, I am not to open a specific record to see its details on form.. Even in Web API we are handling single result method also, but not sure where we are missing. Please do the helpful on the same...

Prior posting the question here I was using a constructor for single retrieve like public SingleResult Get([FromODataUri] Guid key). Now I have changed that to public Person Get(Guid key) and it's working fine.

Related

Opportunity in "Call To" field of "Phone call" activity in Dynamics 365 CE

A requirement from one of our client is that in Dynamics CRM, they want Opportunity entity to show up in the Call To field of a Phone Call entity. I have not been able to find anything online that will tell me how to do this or if this can be done.
In the Call To field of a Phone Call activity only Account, Contact and User entities are available, can we add Opportunity entity here?
Let me start with this two important pieces: Regarding & ActivityParty
Regarding is a special field type (for internal Activity only use, unavailable as datatype) which holds any entity as parent of that CRM Activity. We can only enable this (no disable option). I think this is the one you should be using.
I like this article What developers need to know about the activity entity - by Ben Hosking.
ActivityParty is another special (very special) field type. ie Party List datatype.
Read about it in latest documentation, this is missing a crucial piece from old documentation
An activity party represents another record (person or resource) that’s to be included in the activity. For example, it could be a contact, account, lead, opportunity, or queue.
It should allow to add any entity type, as this will be stored with its respective PartyObjectTypeCode. You can enable/add entity to this bucket by adding Email type field in that entity or simply by checking this checkbox:
You see this is disabled for Opportunity, and I don't remember about the past versions.
Opportunity is not a physical person anyway to be part of a call, but in xRM world anything is fine. You can try by adding an email type field in Opportunity to try your luck.

Get all contacts from marketing list (Dynamics CRM) within Microsoft Flow

I need to sync Dynamics CRM marketing list with a mailing agent (Mailjet via API) and I thought I could use Microsoft Flow for this.
The idea is to trigger flow on marketing list update/create that will generate the JSON with list contacts info and send it via HTTP request. The problem is when I use "List Records" action I can't filter contacts based on marketing list id that I get from "When a record is created or updated (Preview)" on Marketing list entity.
I've tested that this trigger is activated when I add a new contact to a list so it should work fine. A better option will be to trigger flow( or workflow? ) within the Dynamics Marketing List view, but I'm not sure if this is possible. Can I run the JS code with the Marketing List input within Dynamics?
Can anyone point me in the right direction? I don't know C# so I'm looking for the solution on JavaScript or PHP.
Thanks!
i think if you want do it with javascript you should add your Javascript to the OnSave Event of the Marketing List or add Javascript on the OnChange Event of the Marketing List Subgrid for Account/Contact/Lead.
Dynamics CRM Events in forms and grids
Then you can get the marketing list members via Javascript and send it somewhere.
You can retrieve marketing list members via webapi, but you must be aware with static and dynamic marketing list.
Getting List members with webapi
Web Api Samples
...and i think this approach would only work for a small number of members.
So this is indeed possible to do in Flow! Thanks to SGeis for the link to Getting List members with webapi. This link uses the entity name of listmembers to store the items inside of a list, and Marketing List is just a special type of list.
In Flow you can specify a custom Entity name. You can enter listmembers for the entity, and as the link showed you can enter _listid_value eq <Marketing List GUID here> in the Filter Query box. Example below:
It will then return a list of objects that are each pointers to a contact record. In the raw json payload the contact guid is called _entityid_value,
or just Entity when used in the Flow Interface:

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.

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.

Resources