more-xrm is a TypeScript library that enables you to connect, query and manage Dynamics 365 data using the modern fetch API
Create more applications using the Microsoft Dynamics 365/XRM platform
more-xrm
is a TypeScript library that enables you to connect, query and manage Dynamics 365 data using the modern fetch api. Query operations and batch procedures are available for connecting to the Dynamics Web API.
more-xrm enables querying the dynamics data model from any application
Query
interface for describing columns, filters and other query informationQuery
, with formatting and attribute alias namesBatch
interface for describing changesets and committing them in batch
This module is designed for use with Microsoft Dynamics 365 Customer Engagement Web API - either a Web Resource with a relative api path or an authToken
with an associated system user record can be used.
From unpkg (cdn):
<script src="https://unpkg.com/more-xrm"></script>
or
From npm:
npm install more-xrm
Import/Add the dynamics
method from 'more-xrm/dist/Dynamics'
import dynamics from 'more-xrm/dist/Dynamics';
Import/Add query
method and QueryOperator
enum from 'more-xrm/dist/Query'
import query, { QueryOperator } from 'more-xrm/dist/Query';
Create a query
for the Dynamics Account entity:
const accounts = query('account')
.path('accounts') // Indicates Entity Name on Web API Url
.where('name', QueryOperator.Contains, 'xrm')
.orderBy('name')
.select('name');
Call dynamics
to obtain a connection to Dynamics:
const dynamicsClient = dynamics(); //option to pass access token
Execute accounts
query using dynamicsClient
:
dynamicsClient.fetch(accounts).then(results => { /* results is an array of accounts */ });
save
:const accountId = accounts[0].accountid; //account with name like '%xrm%'
dynamicsClient.save('accounts', { name: 'more-xrm' }, accountId).then(id => { /* id of account */ });
An application will query the Account entity in Dynamics where the name contains ‘xrm’, then update the Account name to ‘more-xrm’
import dynamics from 'more-xrm/dist/Dynamics';
import query, { QueryOperator } from 'more-xrm/dist/Query';
//Create a query
const accounts = query('account')
.path('accounts') // Indicates Entity Name on Web API Url
.where('name', QueryOperator.Contains, 'xrm')
.orderBy('name')
.select('name');
//Connect to Dynamics
const dynamicsClient = dynamics();
//Execute accounts query
dynamicsClient.fetch(accounts).then(results => {
if(results.length > 0) {
const accountId = accounts[0].accountid;
//Update data in Dynamics by calling save:
dynamicsClient.save('accounts', { name: 'more-xrm' }, accountId).then(id => {
/* Account was updated */
});
}
});
more-xrm is licensed under the
MIT license