Skip to content

callbacks Class.DynamicsWebApi

Aleksandr Rogov edited this page May 12, 2025 · 2 revisions

dynamics-web-api-wiki / DynamicsWebApi

Class: DynamicsWebApi

Deprecated

Please use DynamicsWebApi with Promises. Will be fully removed in v2.

Constructors

Constructor

new DynamicsWebApi(config?): DynamicsWebApi

DynamicsWebApi constructor

Parameters

Parameter Type Description
config? Config DynamicsWebApi configuration

Returns

DynamicsWebApi

Properties

Property Type Description
utility Utility Utility functions Deprecated please use dynamicsWebApi.Utility instead
Utility Utility Utility functions

Methods

associate()

associate(collection, primaryKey, relationshipName, relatedCollection, relatedKey, successCallback?, errorCallback?, impersonateUserId?): void

Associate for a collection-valued navigation property. (1:N or N:N)

Parameters

Parameter Type Description
collection string Primary Entity Collection name or Entity Name.
primaryKey string Primary entity record id.
relationshipName string Relationship name.
relatedCollection string Related Entity Collection name or Entity Name.
relatedKey string Related entity record id.
successCallback? Function The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
impersonateUserId? string A String representing the GUID value for the Dynamics 365 system user id. Impersonates the user.

Returns

void


associateSingleValued()

associateSingleValued(collection, key, singleValuedNavigationPropertyName, relatedCollection, relatedKey, successCallback?, errorCallback?, impersonateUserId?): void

Associate for a single-valued navigation property. (1:N)

Parameters

Parameter Type Description
collection string The name of the Entity Collection or Entity Logical name.
key string Entity record Id that contains an attribute.
singleValuedNavigationPropertyName string Single-valued navigation property name (usually it's a Schema Name of the lookup attribute).
relatedCollection string Related collection name that the lookup (attribute) points to.
relatedKey string Related entity record id that needs to be associated.
successCallback? Function The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
impersonateUserId? string A String representing the GUID value for the Dynamics 365 system user id. Impersonates the user.

Returns

void


count()

count(collection, successCallback?, errorCallback?, filter?): void

Sends an asynchronous request to count records. IMPORTANT! The count value does not represent the total number of entities in the system. It is limited by the maximum number of entities that can be returned. Returns: Number

Parameters

Parameter Type Description
collection string The name of the Entity Collection or Entity Logical name.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
filter? string Use the $filter system query option to set criteria for which entities will be returned.

Returns

void


countAll()

countAll(collection, successCallback, errorCallback?, filter?, select?): void

Sends an asynchronous request to count records. Returns: Number

Parameters

Parameter Type Description
collection string The name of the Entity Collection or Entity Logical name.
successCallback (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
filter? string Use the $filter system query option to set criteria for which entities will be returned.
select? string[] An Array representing the $select Query Option to control which attributes will be returned.

Returns

void


create()

create<T>(object, collection, successCallback?, errorCallback?, prefer?, select?): void

Sends an asynchronous request to create a new record.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
object T A JavaScript object valid for create operations.
collection string The name of the Entity Collection or Entity Logical name.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
prefer? string | string[] Sets a Prefer header value. For example: ['retrun=representation', 'odata.include-annotations="*"'].
select? string[] An Array representing the $select Query Option to control which attributes will be returned.

Returns

void

Example

var lead = {
   subject: "Test WebAPI",
   firstname: "Test",
   lastname: "WebAPI",
   jobtitle: "Title"
};

dynamicsWebApi.create(lead, "leads", function (id) {
}, function (error) {
});

createAttribute()

createAttribute<T>(entityKey, attributeDefinition, successCallback?, errorCallback?): void

Sends an asynchronous request to create an attribute.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
entityKey string The Entity MetadataId or Alternate Key (such as LogicalName).
attributeDefinition Object Object that describes the attribute.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.

Returns

void


createEntity()

createEntity<T>(entityDefinition, successCallback?, errorCallback?): void

Sends an asynchronous request to create an entity definition.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
entityDefinition Object Entity Definition.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.

Returns

void


createGlobalOptionSet()

createGlobalOptionSet<T>(globalOptionSetDefinition, successCallback?, errorCallback?): void

Sends an asynchronous request to create a Global Option Set definition

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
globalOptionSetDefinition Object Global Option Set Definition.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.

Returns

void


createRelationship()

createRelationship<T>(relationshipDefinition, successCallback?, errorCallback?): void

Sends an asynchronous request to create a relationship definition.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
relationshipDefinition Object Relationship Definition.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.

Returns

void


createRequest()

createRequest<T>(request, successCallback?, errorCallback?): void

Sends an asynchronous request to create a new record.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
request CreateRequest<T> An object that represents all possible options for a current request.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.

Returns

void

Example

var lead = {
   subject: "Test WebAPI",
   firstname: "Test",
   lastname: "WebAPI",
   jobtitle: "Title"
};

var request = {
   entity: lead,
   collection: "leads",
   returnRepresentation: true
}

dynamicsWebApi.createRequest(request, function (response) {
}, function (error) {
});

deleteGlobalOptionSet()

deleteGlobalOptionSet(globalOptionSetKey, successCallback?, errorCallback?): void

Sends an asynchronous request to delete a Global Option Set.

Parameters

Parameter Type Description
globalOptionSetKey string A String representing the GUID value or Alternate Key (such as Name).
successCallback? Function The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.

Returns

void


deleteRecord()

deleteRecord(key, collection, successCallback?, errorCallback?, propertyName?): void

Sends an asynchronous request to delete a record.

Parameters

Parameter Type Description
key string A String representing the GUID value or Alternate Key(s) for the record to delete.
collection string The name of the Entity Collection or Entity Logical name.
successCallback? Function The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
propertyName? string The name of the property which needs to be emptied. Instead of removing a whole record only the specified property will be cleared.

Returns

void


deleteRelationship()

deleteRelationship(metadataId, successCallback?, errorCallback?): void

Sends an asynchronous request to delete a relationship definition.

Parameters

Parameter Type Description
metadataId string A String representing the GUID value.
successCallback? Function The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.

Returns

void


deleteRequest()

deleteRequest(request, successCallback?, errorCallback?): void

Sends an asynchronous request to delete a record.

Parameters

Parameter Type Description
request DeleteRequest An object that represents all possible options for a current request.
successCallback? Function The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.

Returns

void


disassociate()

disassociate(collection, primaryKey, relationshipName, relatedKey, successCallback?, errorCallback?, impersonateUserId?): void

Disassociate for a collection-valued navigation property.

Parameters

Parameter Type Description
collection string Primary Entity Collection name or Entity Name.
primaryKey string Primary entity record id.
relationshipName string Relationship name.
relatedKey string Related entity record id.
successCallback? Function The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
impersonateUserId? string A String representing the GUID value for the Dynamics 365 system user id. Impersonates the user.

Returns

void


disassociateSingleValued()

disassociateSingleValued(collection, key, singleValuedNavigationPropertyName, successCallback?, errorCallback?, impersonateUserId?): void

Removes a reference to an entity for a single-valued navigation property. (1:N)

Parameters

Parameter Type Description
collection string The name of the Entity Collection or Entity Logical name.
key string Entity record Id that contains an attribute.
singleValuedNavigationPropertyName string Single-valued navigation property name (usually it's a Schema Name of the lookup attribute).
successCallback? Function The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
impersonateUserId? string A String representing the GUID value for the Dynamics 365 system user id. Impersonates the user.

Returns

void


downloadFile()

downloadFile(request, successCallback, errorCallback): void

Downloads a file from a file attribute

Parameters

Parameter Type Description
request DownloadRequest An object that represents all possible options for a current request.
successCallback (result) => void The function that will be passed through and be called by a successful response.
errorCallback (error) => void The function that will be passed through and be called by a failed response.

Returns

void


executeBatch()

executeBatch(successCallback, errorCallback, request?): void

Executes a batch request. Please call DynamicsWebApi.startBatch() first to start a batch request.

Parameters

Parameter Type Description
successCallback Function The function that will be passed through and be called by a successful response.
errorCallback Function The function that will be passed through and be called by a failed response.
request? BatchRequest

Returns

void


executeBoundAction()

executeBoundAction<T>(id, collection, actionName, requestObject, successCallback?, errorCallback?, impersonateUserId?): void

Executes a bound Web API action (bound to a particular entity record)

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
id string A String representing the GUID value for the record (pass "null" for an optional parameter)
collection string The name of the Entity Collection or Entity Logical name.
actionName string The name of the Web API action.
requestObject Object Action request body object.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
impersonateUserId? string A String representing the GUID value for the Dynamics 365 system user id. Impersonates the user.

Returns

void


executeBoundFunction()

executeBoundFunction<T>(id, collection, functionName, successCallback?, errorCallback?, parameters?, impersonateUserId?): void

Executes a bound function

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
id string A String representing the GUID value for the record.
collection string The name of the Entity Collection or Entity Logical name.
functionName string The name of the function.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
parameters? Object Function's input parameters. Example: { param1: "test", param2: 3 }.
impersonateUserId? string A String representing the GUID value for the Dynamics 365 system user id. Impersonates the user.

Returns

void


executeFetchXml()

executeFetchXml<T>(collection, fetchXml, successCallback?, errorCallback?, includeAnnotations?, pageNumber?, pagingCookie?, impersonateUserId?): void

Sends an asynchronous request to count records. Returns: DWA.Types.FetchXmlResponse

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
collection string The name of the Entity Collection or Entity Logical name.
fetchXml string FetchXML is a proprietary query language that provides capabilities to perform aggregation.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
includeAnnotations? string Use this parameter to include annotations to a result. For example: * or Microsoft.Dynamics.CRM.fetchxmlpagingcookie
pageNumber? number Page number.
pagingCookie? string Paging cookie. For retrieving the first page, pagingCookie should be null.
impersonateUserId? string A String representing the GUID value for the Dynamics 365 system user id. Impersonates the user.

Returns

void


executeFetchXmlAll()

executeFetchXmlAll<T>(collection, fetchXml, successCallback, errorCallback, includeAnnotations?, impersonateUserId?): void

Sends an asynchronous request to execute FetchXml to retrieve all records.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
collection string The name of the Entity Collection or Entity Logical name.
fetchXml string FetchXML is a proprietary query language that provides capabilities to perform aggregation.
successCallback (result) => void The function that will be passed through and be called by a successful response.
errorCallback (error) => void The function that will be passed through and be called by a failed response.
includeAnnotations? string Use this parameter to include annotations to a result. For example: * or Microsoft.Dynamics.CRM.fetchxmlpagingcookie
impersonateUserId? string A String representing the GUID value for the Dynamics 365 system user id. Impersonates the user.

Returns

void


executeUnboundAction()

executeUnboundAction<T>(actionName, requestObject, successCallback?, errorCallback?, impersonateUserId?): void

Executes an unbound Web API action (not bound to a particular entity record)

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
actionName string The name of the Web API action.
requestObject Object Action request body object.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
impersonateUserId? string A String representing the GUID value for the Dynamics 365 system user id. Impersonates the user.

Returns

void


executeUnboundFunction()

executeUnboundFunction<T>(functionName, successCallback?, errorCallback?, parameters?, impersonateUserId?): void

Executes an unbound function (not bound to a particular entity record)

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
functionName string The name of the function.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
parameters? Object Function's input parameters. Example: { param1: "test", param2: 3 }.
impersonateUserId? string A String representing the GUID value for the Dynamics 365 system user id. Impersonates the user.

Returns

void


fetch()

fetch<T>(collection, fetchXml, successCallback?, errorCallback?, includeAnnotations?, pageNumber?, pagingCookie?, impersonateUserId?): void

Sends an asynchronous request to count records. Returns: DWA.Types.FetchXmlResponse

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
collection string The name of the Entity Collection or Entity Logical name.
fetchXml string FetchXML is a proprietary query language that provides capabilities to perform aggregation.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
includeAnnotations? string Use this parameter to include annotations to a result. For example: * or Microsoft.Dynamics.CRM.fetchxmlpagingcookie
pageNumber? number Page number.
pagingCookie? string Paging cookie. For retrieving the first page, pagingCookie should be null.
impersonateUserId? string A String representing the GUID value for the Dynamics 365 system user id. Impersonates the user.

Returns

void


fetchAll()

fetchAll<T>(collection, fetchXml, successCallback, errorCallback, includeAnnotations?, impersonateUserId?): void

Sends an asynchronous request to execute FetchXml to retrieve all records.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
collection string The name of the Entity Collection or Entity Logical name.
fetchXml string FetchXML is a proprietary query language that provides capabilities to perform aggregation.
successCallback (result) => void The function that will be passed through and be called by a successful response.
errorCallback (error) => void The function that will be passed through and be called by a failed response.
includeAnnotations? string Use this parameter to include annotations to a result. For example: * or Microsoft.Dynamics.CRM.fetchxmlpagingcookie
impersonateUserId? string A String representing the GUID value for the Dynamics 365 system user id. Impersonates the user.

Returns

void


initializeInstance()

initializeInstance(config?): DynamicsWebApi

Creates a new instance of DynamicsWebApi

Parameters

Parameter Type Description
config? Config configuration object.

Returns

DynamicsWebApi


retrieve()

retrieve<T>(key, collection, successCallback?, errorCallback?, select?, expand?): void

Sends an asynchronous request to retrieve a record.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
key string A String representing the GUID value or Alternate Key(s) for the record to retrieve.
collection string The name of the Entity Collection or Entity Logical name.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
select? string[] An Array representing the $select Query Option to control which attributes will be returned.
expand? Expand[] A String or Array of Expand Objects representing the $expand Query Option value to control which related records need to be returned.

Returns

void


retrieveAll()

retrieveAll<T>(collection, successCallback, errorCallback, select?, filter?): void

Sends an asynchronous request to retrieve all records.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
collection string The name of the Entity Collection or Entity Logical name.
successCallback (result) => void The function that will be passed through and be called by a successful response.
errorCallback (error) => void The function that will be passed through and be called by a failed response.
select? string[] Use the $select system query option to limit the properties returned.
filter? string Use the $filter system query option to set criteria for which entities will be returned.

Returns

void


retrieveAllRequest()

retrieveAllRequest<T>(request, successCallback, errorCallback): void

Sends an asynchronous request to retrieve all records.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
request RetrieveMultipleRequest An object that represents all possible options for a current request.
successCallback (result) => void The function that will be passed through and be called by a successful response.
errorCallback (error) => void The function that will be passed through and be called by a failed response.

Returns

void


retrieveAttribute()

retrieveAttribute<T>(entityKey, attributeKey, successCallback?, errorCallback?, attributeType?, select?, expand?): void

Sends an asynchronous request to retrieve a specific attribute metadata for a specified entity definition.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
entityKey string The Entity MetadataId or Alternate Key (such as LogicalName).
attributeKey string The Attribute Metadata id.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
attributeType? string Use this parameter to cast the Attribute to a specific type.
select? string[] Use the $select system query option to limit the properties returned.
expand? Expand[] A String or Array of Expand Objects representing the $expand Query Option value to control which related records need to be returned.

Returns

void


retrieveAttributes()

retrieveAttributes<T>(entityKey, successCallback?, errorCallback?, attributeType?, select?, filter?, expand?): void

Sends an asynchronous request to retrieve attribute metadata for a specified entity definition.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
entityKey string The Entity MetadataId or Alternate Key (such as LogicalName).
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
attributeType? string Use this parameter to cast the Attributes to a specific type.
select? string[] Use the $select system query option to limit the properties returned.
filter? string Use the $filter system query option to set criteria for which attribute definitions will be returned.
expand? Expand[] A String or Array of Expand Objects representing the $expand Query Option value to control which related records need to be returned.

Returns

void


retrieveEntities()

retrieveEntities<T>(successCallback?, errorCallback?, select?, filter?): void

Sends an asynchronous request to retrieve entity definitions.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
select? string[] Use the $select system query option to limit the properties returned.
filter? string Use the $filter system query option to set criteria for which entity definitions will be returned.

Returns

void


retrieveEntity()

retrieveEntity<T>(entityKey, successCallback?, errorCallback?, select?, expand?): void

Sends an asynchronous request to retrieve a specific entity definition.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
entityKey string The Entity MetadataId or Alternate Key (such as LogicalName).
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
select? string[] Use the $select system query option to limit the properties returned.
expand? Expand[] A String or Array of Expand Objects representing the $expand Query Option value to control which related records need to be returned.

Returns

void


retrieveGlobalOptionSet()

retrieveGlobalOptionSet<T>(globalOptionSetKey, successCallback?, errorCallback?, castType?, select?): void

Sends an asynchronous request to retrieve Global Option Set definitions.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
globalOptionSetKey string The Global Option Set MetadataID or Alternate Key (such as Name).
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
castType? string Use this parameter to cast a Global Option Set to a specific type.
select? string[] Use the $select system query option to limit the properties returned

Returns

void


retrieveGlobalOptionSets()

retrieveGlobalOptionSets<T>(successCallback?, errorCallback?, castType?, select?): void

Sends an asynchronous request to retrieve Global Option Set definitions.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
castType? string Use this parameter to cast a Global Option Set to a specific type.
select? string[] Use the $select system query option to limit the properties returned

Returns

void


retrieveMultiple()

retrieveMultiple<T>(collection, successCallback?, errorCallback?, select?, filter?, oDataLink?): void

Sends an asynchronous request to retrieve records.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
collection string The name of the Entity Collection or Entity Logical name.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
select? string[] Use the $select system query option to limit the properties returned.
filter? string Use the $filter system query option to set criteria for which entities will be returned.
oDataLink? string Use this parameter to pass @odata.nextLink or @odata.deltaLink to return a necessary response. Pass null to retrieveMultipleOptions.

Returns

void


retrieveMultipleRequest()

retrieveMultipleRequest<T>(request, successCallback?, errorCallback?, oDataLink?): void

Sends an asynchronous request to retrieve records.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
request RetrieveMultipleRequest An object that represents all possible options for a current request.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
oDataLink? string Use this parameter to pass @odata.nextLink or @odata.deltaLink to return a necessary response. Pass null to retrieveMultipleOptions.

Returns

void


retrieveRelationship()

retrieveRelationship<T>(metadataId, successCallback?, errorCallback?, relationshipType?, select?): void

Sends an asynchronous request to retrieve a specific relationship definition.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
metadataId string String representing the Metadata Id GUID.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
relationshipType? string Use this parameter to cast a Relationship to a specific type: 1:M or M:M.
select? string[] Use the $select system query option to limit the properties returned.

Returns

void


retrieveRelationships()

retrieveRelationships<T>(successCallback?, errorCallback?, relationshipType?, select?, filter?): void

Sends an asynchronous request to retrieve relationship definitions.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
relationshipType? string Use this parameter to cast a Relationship to a specific type: 1:M or M:M.
select? string[] Use the $select system query option to limit the properties returned.
filter? string Use the $filter system query option to set criteria for which relationships will be returned.

Returns

void


retrieveRequest()

retrieveRequest<T>(request, successCallback?, errorCallback?): void

Sends an asynchronous request to retrieve a record.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
request RetrieveRequest An object that represents all possible options for a current request.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.

Returns

void


setConfig()

setConfig(config): void

Sets DynamicsWebApi configuration parameters.

Parameters

Parameter Type Description
config Config configuration object

Returns

void

Example

dynamicsWebApi.setConfig({ webApiVersion: '9.1' });

startBatch()

startBatch(): void

Starts a batch request.

Returns

void


update()

update<T>(key, collection, object, successCallback?, errorCallback?, prefer?, select?): void

Sends an asynchronous request to update a record.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
key string A String representing the GUID value or Alternate Key(s) for the record to update.
collection string The name of the Entity Collection or Entity Logical name.
object T A JavaScript object valid for update operations.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
prefer? string | string[] If set to "return=representation" the function will return an updated object
select? string[] An Array representing the $select Query Option to control which attributes will be returned.

Returns

void


updateAttribute()

updateAttribute<T>(entityKey, attributeDefinition, successCallback?, errorCallback?, attributeType?, mergeLabels?): void

Sends an asynchronous request to update an attribute.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
entityKey string The Entity MetadataId or Alternate Key (such as LogicalName).
attributeDefinition Object Object that describes the attribute.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
attributeType? string Use this parameter to cast the Attribute to a specific type.
mergeLabels? boolean Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false.

Returns

void


updateEntity()

updateEntity<T>(entityDefinition, successCallback?, errorCallback?, mergeLabels?): void

Sends an asynchronous request to update an entity definition.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
entityDefinition Object Entity Definition.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
mergeLabels? boolean Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false.

Returns

void


updateGlobalOptionSet()

updateGlobalOptionSet<T>(globalOptionSetDefinition, successCallback?, errorCallback?, mergeLabels?): void

Sends an asynchronous request to update a Global Option Set.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
globalOptionSetDefinition Object Global Option Set Definition.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
mergeLabels? boolean Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false.

Returns

void


updateRelationship()

updateRelationship<T>(relationshipDefinition, successCallback?, errorCallback?, relationshipType?, mergeLabels?): void

Sends an asynchronous request to update a relationship definition.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
relationshipDefinition Object Relationship Definition.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
relationshipType? string Use this parameter to cast the Relationship to a specific type.
mergeLabels? boolean Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false.

Returns

void


updateRequest()

updateRequest<T>(request, successCallback?, errorCallback?): void

Sends an asynchronous request to update a record.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
request UpdateRequest<T> An object that represents all possible options for a current request.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.

Returns

void


updateSingleProperty()

updateSingleProperty(key, collection, keyValuePair, successCallback?, errorCallback?, prefer?, select?): void

Sends an asynchronous request to update a single value in the record.

Parameters

Parameter Type Description
key string A String representing the GUID value or Alternate Key(s) for the record to update.
collection string The name of the Entity Collection or Entity Logical name.
keyValuePair {[key: string]: any; } keyValuePair object with a logical name of the field as a key and a value to update with. Example: {subject: "Update Record"}
successCallback? Function The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
prefer? string | string[] If set to "return=representation" the function will return an updated object
select? string[] An Array representing the $select Query Option to control which attributes will be returned.

Returns

void


uploadFile()

uploadFile(request, successCallback, errorCallback): void

Uploads a file to a file attribute

Parameters

Parameter Type Description
request UploadRequest An object that represents all possible options for a current request.
successCallback () => void The function that will be passed through and be called by a successful response.
errorCallback (error) => void The function that will be passed through and be called by a failed response.

Returns

void


upsert()

upsert<T>(key, collection, object, successCallback?, errorCallback?, prefer?, select?): void

Sends an asynchronous request to upsert a record.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
key string A String representing the GUID value or Alternate Key(s) for the record to upsert.
collection string The name of the Entity Collection or Entity Logical name.
object T A JavaScript object valid for update operations.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.
prefer? string | string[] If set to "return=representation" the function will return an updated object
select? string[] An Array representing the $select Query Option to control which attributes will be returned.

Returns

void


upsertRequest()

upsertRequest<T>(request, successCallback?, errorCallback?): void

Sends an asynchronous request to upsert a record.

Type Parameters

Type Parameter Default type
T any

Parameters

Parameter Type Description
request UpsertRequest<T> An object that represents all possible options for a current request.
successCallback? (result) => void The function that will be passed through and be called by a successful response.
errorCallback? (error) => void The function that will be passed through and be called by a failed response.

Returns

void

API

Namespaces

Classes

Clone this wiki locally