Dynamics WebAPI: Update only changed fields? - dynamics-crm

I am writing an application that accesses Dynamics 365 CE via the webapi (v9.0 / 9.1). My application retrieves a record and displays that to the user, the user can make changes and save the record again.
In that case, my application will attempt to save the changes using a Patch call against the Dynamics WebAPI.
Is there a built in way of updating only the fields that the user had changes? This is in a web application where I can't be sure to be able to have a proper client side change tracking, meaning I either have to do another call against the CRM, compare both records and send only the updated values to the CRM or send the entire record to the CRM. The second case is obviously much more performant and easier but I can't seem to find a way to tell the WebAPI to only update the changed fields..

Retrieval of record attributes using web API & binding the values to UI controls, identifying the dirty attributes & update back the source system with only those dirty fields - this is what usual cycle will be.
What you have is issue in identifying the dirty fields - it is not actual change tracking. Try to identify them in client side using an efficient way before submitting a update server request (PATCH).
Sending whole record field values irrespective of its dirtiness is not recommended for various reasons like losing Audit track, pipeline business logic in CRM Plugin/Workflow, etc.

Related

Dynamics CRM appointments list of a related record

I would like to have inside a form, the Activity panel of a related record, in particular for being able to create and modify the appointments of a lead that is related to the current record. I haven't found an out-of-the-box possibility to do this (for example a quick view form), or an external addon. But I want to try to ask: is it possible, or I need to develop a web resource, if this is worth it?

Logic App Dynamics Connector - Record Updated - Which fields have changed?

I am building an integration system using Logic Apps connector to get details of updated records in Dynamics.
I only want to take action when certain fields have changed.
My problem is that the output from the connector shows all the fields after the record is updated.
I'd like to know which fields have changed so my Logic App can decide whether or not to take action.
Does anybody have any ideas? I was thinking of triggering the logic app via HTTP POST and post from inside a custom workflow activity when certain fields change but I wanted to hear if anyone has a better solution first using just the Logic App with Dynamics connector.
Logic app connector for Dynamics 365 exposing triggers which has record level checkpoints like create/update/delete but does not have field level filtering granularity.
Probably your decision is correct by going with Custom WF activity or a Plugin that triggers on filtering attributes of your choice, then invoking Logic app within Plugin/WF using HTTP POST.
Replacement Dataverse connector has ability to trigger based on specific changed fields using following options:
Select columns - filteringattributes - string: Enter a comma-separated list of column unique names. The flow triggers if any of them are
modified
Filter rows - filterexpression - string: Odata expression to limit rows that can trigger the flow, eg. statecode eq 0
Note: [As of 2022-Nov] The new connector is not yet available for LogicApps.
"Microsoft Dataverse (legacy) connector will be supported by Microsoft until the Microsoft Dataverse connector supports Logic Apps."
The new connector is available in PowerApps - the experience was 99% identical, difference appears to be a different billing/organizational model than Azure Logic Apps.

Need real time example of an action in Microsoft dynamics CRM

In Microsoft Dynamics CRM, I know the requirements when to use the plugin, workflows and custom workflows, but I cannot come across those cases or situations when I can use the actions or custom actions.
Can anybody suggest me real time requirement when to use the action?
If possible, please demonstrate an "action" with an example.
Thanks,
Actions are really a supported way to create a custom request, that performs a custom action (or more likely, set of actions) and returns a custom response. I'd say the most likely use case is if you have an external system that needs to perform a set of actions in CRM. Let's say the external system handles phone calls, and needs to create an account, and a phone call record. The custom action could accept the phone number and a couple other fields and then generate the Account, Phone Call, and associate the phone call to the account all in one SOAP request.
One simple use is when you need to execute some server side code from JavaScript by clicking a button in the ribbon OR any where in the client side(not on an entity delete, update, create etc.... messages.) , then you need to create an Action.
e.g if you have to implement some logic and you feel it would be very complex Or not possible on client side (JavaScript), then you should just create an action, implement your logic in that action(server side) and call that action in JavaScript.
For more Info Actions

MS CRM update entity without change modified at and modified by

I've created a custom field in MS CRM 4 entiry used for calculations. Usually it would be filled by the plug-in handler.
How could I initialize this field for all records without changing the "modified at" and "modified by" fields?
Is it possible from Web Service API?
I've heard of people running a SQL UPDATE statements on the CRM tables without adverse effects. I've even had MSFT premier support give me an UPDATE statement to fix a problem with a user's record.

Designing Web services for AJAX Consumption

We are in the process of designing/creating restful web services that will be consumed client side using XHR calls from various web pages. These web pages will contain components that will be populated by the data retrieved from the web services.
My question is, is it best to design the return data of the web services to match specifically what the client side components will require for each page? Therefore, only one XHR call will be required to retrieve all the data necessary to populate a specific AJAX component or to update a specific page. Or is it more advisable to develop generic web services, that match for instance a database schema, and will require multiple XHR calls client side to retrieve all the data to populate an AJAX component? The second approach seems to lead to some messy coding to chain calls together to retrieved all the data required before updating an AJAX component.
Hopefully this makes sense.
You should always design services based on what they are to provide. Unless you need a service that retrieves rows from the database, don't create one. You may find you need a service that returns complete business entities - they may be in multiple tables.
Or, you may just need a service to provide data for UI controls. In that case, that's what you should do. You may later find that two operations are returning almost the same data, so you may refactor that into one operation that returns the data for both.
My general rule of thumb is to do what ever is the smallest to transmit over the ajax call. In theory, the more data that is sent to the client the slower the update process. This, of course, would necessarily mean specific services for specific pages.

Resources