DynamicsWebApi
DynamicsWebApi is a Microsoft Dataverse Web API helper library for JavaScript & TypeScript
Install / Use
/learn @AleksandrRogov/DynamicsWebApiREADME
DynamicsWebApi for Microsoft Dataverse Web API / Microsoft Power Pages / Microsoft Dynamics 365 (CRM)
DynamicsWebApi is a Microsoft Dataverse Web API helper library written in Typescript.
Compatible with: Microsoft Dataverse; Microsoft Dynamics 365: Customer Service, Field Service, Marketing, Project Operations, Talents, Sales and any model-driven application built on Microsoft Power Apps platform. As well as Microsoft Dynamics 365 CE (online), Microsoft Dynamics 365 CE (on-premises), Microsoft Dynamics CRM 2016, Microsoft Dynamics CRM Online.
This documentation is for version 2.x. If you are working with version 1.x, please check this instead.
If you want to upgrade from v1 - v2 breaking changes are here. List of new features in v2 is here.
Please check DynamicsWebApi Wiki where you will find documentation to DynamicsWebApi API and more.
Changelog can be found here.
Browser-compiled script and type definitions can be found in a v2 dist folder.
Main Features
- Microsoft Dataverse Search API. Access the full power of its Search (Query), Suggestion and Autocomplete capabilities.
- Batch Requests. Convert all requests into a Batch operation with two lines of code.
- Simplicity and Automation. Such as automated paging, big file downloading/uploading in chunks of data, automated conversion of requests with long URLs into a Batch Request in the background and more!
- CRUD operations. Including Fetch XML, Actions and Functions in Microsoft Dataverse Web API.
- Table Definitions (Entity Metadata). Query and modify Table, Column, Choice (Option Set) and Relationship definitions.
- File Fields. Upload, Download and Delete data stored in the File Fields.
- Abort Signal and Abort Controller (Browser and Node.js 15+). Abort requests when they are no longer need to be completed.
- Node.js and a Browser support.
- Proxy Configuration support.
- Background Operations support.
v2.3.0+ - Works with Microsoft Power Pages (aka Microsoft Portal).
v2.1.0+
I maintain this project in my free time and it takes a considerable amount of time to make sure that the library has all new features, gets improved and all raised tickets have been answered and fixed in a short amount of time. If you feel that this project has saved your time and you would like to support it, then please feel free to sponsor it through GitHub Sponsors.
Also, please check suggestions and contributions section to learn more about how you can help to improve the library.
Terminology
Check out Dataverse Terminology. Microsoft has done some changes in the namings of the objects and components of D365 and since DynamicsWebApi has been developing for many years there may be conflicting naming, such as: createEntity - which right now means "Create a Table Definition". Dataverse SDK terminology is what the library has been based on. I have no plans on changing that (except in documentation), mainly because Microsoft may change the namings again in the future which will lead to naming issues ...again.
[!NOTE] "Dynamics 365" in this readme refers to Microsoft Dataverse (formerly known as Microsoft Common Data Service) / Microsoft Dynamics 365 Customer Engagement / Micorosft Dynamics CRM. NOT Microsoft Dynamics 365 Finance and Operations.
Table of Contents
v2 breaking changes are here. List of new features in v2 is here.
- Getting Started
- Request Examples
- Create a Table Row
- Update a Table Row
- Update a value in a single column
- Upsert a Table Row
- Delete a Table Row
- Retrieve a Table Row
- Retrieve Multiple Table Rows
- Count
- Associate
- Associate for a single-valued navigation property
- Disassociate
- Disassociate for a single-valued navigation property
- Fetch XML Request
- Execute Web API functions
- Execute Web API actions
- Batch Operations
- Work with Table Definitions (Entity Metadata)
- Tables
- Create a new Table Definition
- Retrieve Table Definitions
- Update Table Definitions
- Retrieve Multiple Table Definitions
- Columns
- Create Columns
- Retrieve Columns
- Update Columns
- Retrieve Multiple Columns
- Use requests to query Table and Column definitions
- Relationships
- Create Relationship
- Update Relationship
- Delete Relationship
- Retrieve Relationship
- Retrieve Multiple Relationships
- Use multi-table lookup columns (Polymorfic Lookup Attributes)
- Global Option Sets (Choices)
- Create Global Option Set
- Update Global Option Set
- Delete Global Option Set
- Retrieve Global Option Set
- Retrieve Multiple Global Option Sets
- Work with File Fields/Columns
- Work with Dataverse Search API
- Retrieve CSDL $metadata document
- Background Operations
- Abort Request
- Formatted Values and Lookup Columns
- Using Alternate Keys
- Making requests using Entity Logical Names
- Using Proxy
- Using TypeScript Declaration Files
- In Progress / Feature List
- Contributions
Getting Started
Dynamics 365 Web Resource
To use DynamicsWebApi inside Dynamics 365 you need to download a browser version of the library, it can be found in v2 dist folder.
Upload a script as a JavaScript Web Resource, add it to a table form or reference it in the HTML Web Resource and then initialize the main object:
//By default DynamicsWebApi makes calls to
//Web API v9.2 and Search API v1.0
const dynamicsWebApi = new DynamicsWebApi();
const response = await dynamicsWebApi.callFunction("WhoAmI");
Xrm.Navigation.openAlertDialog({ text: `Hello Dynamics 365! My id is: ${response.UserId}` });
Microsoft Power Pages (Microsoft Portal)
v.2.1.0+
There are two ways to include DynamicsWebApi in your portal: upload as a Web File or use CDN, such as unpkg.
It is possible to upload the library as a Web File in Microsoft Power Pages. Usually, the .js extensions are forbidden to upload but it is still possible to do, here's a workaround.
Once the web file is uploaded, it can be included in a template, a page or a form the following way:
<script type="text/javascript" src="~/dynamicsWebApi.min.js"></script>
With CDN, it is a bit easier: no need to create and upload a web file - just include the script in your
