or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

batch-processing.mdconfiguration-utilities.mdcrm-actions-functions.mdcrud-operations.mdentity-associations.mdindex.md
tile.json

tessl/npm-xrm-webapi-client

Comprehensive JavaScript framework for Microsoft Dynamics CRM/365 WebAPI integration with promise-based CRUD operations, batch processing, and 200+ pre-implemented actions

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/xrm-webapi-client@4.1.x

To install, run

npx @tessl/cli install tessl/npm-xrm-webapi-client@4.1.0

index.mddocs/

XRM WebAPI Client

XRM WebAPI Client is a comprehensive JavaScript framework for working with Microsoft Dynamics CRM/365 Web API. It provides both synchronous and asynchronous operations through promise-based architecture using Bluebird, supporting complete CRUD operations, advanced querying with FetchXML and OData, batch processing, and 200+ pre-implemented CRM actions.

Package Information

  • Package Name: xrm-webapi-client
  • Package Type: npm
  • Language: JavaScript with TypeScript definitions
  • Installation: npm install xrm-webapi-client

Core Imports

import * as WebApiClient from "xrm-webapi-client";

For CommonJS:

const WebApiClient = require("xrm-webapi-client");

Basic Usage

import * as WebApiClient from "xrm-webapi-client";

// Configure the client
WebApiClient.ApiVersion = "9.0";
WebApiClient.ReturnAllPages = true;
WebApiClient.PrettifyErrors = false;

// Create a record
const accountId = await WebApiClient.Create({
    entityName: "account",
    entity: {
        name: "Contoso Corporation",
        telephone1: "555-0123",
        websiteurl: "https://contoso.com"
    }
});

// Retrieve a record
const account = await WebApiClient.Retrieve({
    entityName: "account",
    entityId: accountId,
    queryParams: "?$select=name,telephone1,websiteurl"
});

// Update a record
await WebApiClient.Update({
    entityName: "account",
    entityId: accountId,
    entity: { telephone1: "555-9999" }
});

// Delete a record
await WebApiClient.Delete({
    entityName: "account",
    entityId: accountId
});

Architecture

XRM WebAPI Client is built around several key components:

  • Core Module: Main CRUD operations and client configuration
  • Promise Integration: Bluebird promises for cross-browser compatibility and advanced promise features
  • Batch Processing: Transaction-based batch operations with change sets
  • Request Library: 200+ pre-implemented CRM actions and functions
  • Type System: Full TypeScript definitions with interfaces for all parameters and responses
  • Context Detection: Automatic CRM context detection for forms, web resources, and external SPAs

Capabilities

CRUD Operations

Core create, retrieve, update, and delete operations for CRM entities with support for alternate keys, query parameters, and FetchXML.

function Create(parameters: CreateParameters): Promise<string> | Promise<any> | string | any | BatchRequest;
function Retrieve(parameters: RetrieveParameters): Promise<any> | any | BatchRequest;
function Update(parameters: UpdateParameters): Promise<string> | Promise<any> | string | any | BatchRequest;
function Delete(parameters: DeleteParameters): Promise<string> | string | BatchRequest;

interface CreateParameters extends BaseParameters {
    entityName?: string;
    overriddenSetName?: string;
    entity: object;
}

interface RetrieveParameters extends BaseParameters {
    entityName?: string;
    overriddenSetName?: string;
    entityId?: string;
    alternateKey?: Array<Key>;
    queryParams?: string;
    fetchXml?: string;
    returnAllPages?: boolean;
}

interface UpdateParameters extends BaseParameters {
    entityName?: string;
    overriddenSetName?: string;
    entityId?: string;
    entity: object;
    alternateKey?: Array<Key>;
}

interface DeleteParameters extends BaseParameters {
    entityName?: string;
    overriddenSetName?: string;
    entityId?: string;
    alternateKey?: Array<Key>;
}

CRUD Operations

Entity Associations

Associate and disassociate operations for managing relationships between CRM entities.

function Associate(parameters: AssociationParameters): Promise<string> | string | BatchRequest;
function Disassociate(parameters: AssociationParameters): Promise<string> | string | BatchRequest;

interface AssociationParameters extends BaseParameters {
    relationShip: string;
    source: EntityReference;
    target: EntityReference;
}

interface EntityReference {
    entityName: string;
    entityId: string;
}

Entity Associations

Batch Processing

Transaction-based batch operations allowing multiple requests to be sent together with rollback capabilities.

function SendBatch(batch: Batch): Promise<BatchResponse> | BatchResponse;

class Batch implements BatchParameters {
    name?: string;
    changeSets?: Array<ChangeSet>;
    requests?: Array<BatchRequest>;
    headers?: Array<Header>;
    async?: boolean;
    isOverLengthGet?: boolean;

    constructor(parameters: BatchParameters);
}

class BatchResponse implements BatchResponseParameters {
    name?: string;
    changeSetResponses?: Array<ChangeSetResponse>;
    batchResponses?: Array<Response>;
    isFaulted?: boolean;
    errors?: Array<string>;
    xhr?: XMLHttpRequest;

    constructor(parameters: BatchResponseParameters);
}

Batch Processing

CRM Actions and Functions

Execute pre-implemented CRM actions and functions, or create custom request objects.

function Execute(request: object): Promise<any> | any | BatchRequest;

namespace Requests {
    class Request implements RequestParameters {
        method?: string;
        name?: string;
        bound?: boolean;
        entityName?: string;
        entityId?: string;
        payload?: object;
        headers?: Array<Header>;
        urlParams?: object;
        async?: boolean;

        with(param: RequestParameters): this;
    }
}

CRM Actions and Functions

Configuration and Utilities

Client configuration, URL building, header management, and utility functions.

import * as bluebird from "bluebird";

function GetApiUrl(): string;
function GetSetName(entity: string): string;
function SendRequest(method: string, url: string, payload: object, parameters?: BaseParameters): Promise<any> | any | BatchRequest;

// Configuration Properties
let ApiVersion: string;
let ReturnAllPages: boolean;
let PrettifyErrors: boolean;
let Async: boolean;
let ClientUrl: string;
let Token: string;
let Version: string;
let Promise: typeof bluebird;

Configuration and Utilities

Core Types

interface BaseParameters {
    async?: boolean;
    headers?: Array<Header>;
    asBatch?: boolean;
    apiVersion?: string;
}

interface Header {
    key: string;
    value: string;
}

interface Key {
    property: string;
    value: string | number;
}