Skip to content

Commit 3fb15f7

Browse files
Release v1.2.4
1 parent 4bd45d0 commit 3fb15f7

File tree

6 files changed

+105
-47
lines changed

6 files changed

+105
-47
lines changed

dist/dwa.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! dwa v1.2.3 (c) 2017 Aleksandr Rogov */
1+
/*! dwa v1.2.4 (c) 2017 Aleksandr Rogov */
22
(function webpackUniversalModuleDefinition(root, factory) {
33
if(typeof exports === 'object' && typeof module === 'object')
44
module.exports = factory();

dist/dynamics-web-api-callbacks.js

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! dynamics-web-api-callbacks v1.2.3 (c) 2017 Aleksandr Rogov */
1+
/*! dynamics-web-api-callbacks v1.2.4 (c) 2017 Aleksandr Rogov */
22
(function webpackUniversalModuleDefinition(root, factory) {
33
if(typeof exports === 'object' && typeof module === 'object')
44
module.exports = factory();
@@ -1485,6 +1485,27 @@ function DynamicsWebApi(config) {
14851485
}
14861486
}
14871487

1488+
/**
1489+
* Sends an asynchronous request to count records. Returns: Number
1490+
*
1491+
* @param {string} collection - The Name of the Entity Collection.
1492+
* @param {Function} successCallback - The function that will be passed through and be called by a successful response.
1493+
* @param {Function} errorCallback - The function that will be passed through and be called by a failed response.
1494+
* @param {string} [filter] - Use the $filter system query option to set criteria for which entities will be returned.
1495+
* @param {Array} [select] - An Array representing the $select Query Option to control which attributes will be returned.
1496+
*/
1497+
this.countAll = function (collection, successCallback, errorCallback, filter, select) {
1498+
return this.retrieveAllRequest({
1499+
collection: collection,
1500+
filter: filter,
1501+
select: select
1502+
}, function (response) {
1503+
successCallback(response
1504+
? (response.value ? response.value.length : 0)
1505+
: 0);
1506+
}, errorCallback);
1507+
}
1508+
14881509
/**
14891510
* Sends an asynchronous request to retrieve records.
14901511
*
@@ -1512,7 +1533,7 @@ function DynamicsWebApi(config) {
15121533
* @param {Function} errorCallback - The function that will be passed through and be called by a failed response.
15131534
* @param {string} [nextPageLink] - Use the value of the @odata.nextLink property with a new GET request to return the next page of data. Pass null to retrieveMultipleOptions.
15141535
*/
1515-
this.retrieveMultipleRequest = function (request, successCallback, errorCallback, nextPageLink) {
1536+
var retrieveMultipleRequest = function (request, successCallback, errorCallback, nextPageLink) {
15161537

15171538
ErrorHelper.callbackParameterCheck(successCallback, "DynamicsWebApi.retrieveMultiple", "successCallback");
15181539
ErrorHelper.callbackParameterCheck(errorCallback, "DynamicsWebApi.retrieveMultiple", "errorCallback");
@@ -1550,6 +1571,37 @@ function DynamicsWebApi(config) {
15501571
_sendRequest("GET", result.url, null, result.headers, onSuccess, errorCallback);
15511572
}
15521573

1574+
this.retrieveMultipleRequest = retrieveMultipleRequest;
1575+
1576+
var _retrieveAllRequest = function (request, successCallback, errorCallback, nextPageLink, records) {
1577+
1578+
var records = records || [];
1579+
1580+
var internalSuccessCallback = function (response) {
1581+
records = records.concat(response.value);
1582+
1583+
if (response.oDataNextLink) {
1584+
_retrieveAllRequest(request, successCallback, errorCallback, response.oDataNextLink, records);
1585+
}
1586+
else {
1587+
successCallback({ value: records });
1588+
}
1589+
};
1590+
1591+
retrieveMultipleRequest(request, internalSuccessCallback, errorCallback, nextPageLink);
1592+
};
1593+
1594+
/**
1595+
* Sends an asynchronous request to retrieve all records.
1596+
*
1597+
* @param {Object} request - An object that represents all possible options for a current request.
1598+
* @param {Function} successCallback - The function that will be passed through and be called by a successful response.
1599+
* @param {Function} errorCallback - The function that will be passed through and be called by a failed response.
1600+
*/
1601+
this.retrieveAllRequest = function (request, successCallback, errorCallback) {
1602+
_retrieveAllRequest(request, successCallback, errorCallback);
1603+
}
1604+
15531605
/**
15541606
* Sends an asynchronous request to count records. Returns: DWA.Types.FetchXmlResponse
15551607
*

dist/dynamics-web-api-callbacks.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dynamics-web-api.js

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! dynamics-web-api v1.2.3 (c) 2017 Aleksandr Rogov */
1+
/*! dynamics-web-api v1.2.4 (c) 2017 Aleksandr Rogov */
22
(function webpackUniversalModuleDefinition(root, factory) {
33
if(typeof exports === 'object' && typeof module === 'object')
44
module.exports = factory();
@@ -981,7 +981,7 @@ function DynamicsWebApi(config) {
981981
};
982982

983983
var _initUrl = function () {
984-
return _getClientUrl() + "/api/data/v" + _internalConfig.webApiVersion + "/";
984+
return _getClientUrl() + "/api/data/v" + _internalConfig.webApiVersion + "/";
985985
};
986986

987987
/**
@@ -990,7 +990,7 @@ function DynamicsWebApi(config) {
990990
* @param {DWAConfig} config - configuration object
991991
*/
992992
this.setConfig = function (config) {
993-
993+
994994
if (config.webApiVersion) {
995995
ErrorHelper.stringParameterCheck(config.webApiVersion, "DynamicsWebApi.setConfig", "config.webApiVersion");
996996
_internalConfig.webApiVersion = config.webApiVersion;
@@ -1403,7 +1403,7 @@ function DynamicsWebApi(config) {
14031403
* @param {string} [nextPageLink] - Use the value of the @odata.nextLink property with a new GET request to return the next page of data. Pass null to retrieveMultipleOptions.
14041404
* @returns {Promise}
14051405
*/
1406-
this.retrieveMultipleRequest = function (request, nextPageLink) {
1406+
var retrieveMultipleRequest = function (request, nextPageLink) {
14071407

14081408
if (nextPageLink && !request.collection) {
14091409
request.collection = "any";
@@ -1437,46 +1437,31 @@ function DynamicsWebApi(config) {
14371437
});
14381438
};
14391439

1440+
this.retrieveMultipleRequest = retrieveMultipleRequest;
1441+
1442+
var _retrieveAllRequest = function (request, nextPageLink, records) {
1443+
var records = records || [];
1444+
1445+
return retrieveMultipleRequest(request, nextPageLink).then(function (response) {
1446+
records = records.concat(response.value);
1447+
1448+
if (response.oDataNextLink) {
1449+
return _retrieveAllRequest(request, response.oDataNextLink, records);
1450+
}
1451+
1452+
return { value: records };
1453+
});
1454+
}
1455+
14401456
/**
1441-
* Sends an asynchronous request to retrieve records.
1457+
* Sends an asynchronous request to retrieve all records.
14421458
*
14431459
* @param {Object} request - An object that represents all possible options for a current request.
1444-
* @param {string} [nextPageLink] - Use the value of the @odata.nextLink property with a new GET request to return the next page of data. Pass null to retrieveMultipleOptions.
14451460
* @returns {Promise}
14461461
*/
1447-
//var retrieveMultipleRequestAll = function (request) {
1448-
1449-
// if (nextPageLink && !request.collection) {
1450-
// request.collection = "any";
1451-
// }
1452-
1453-
// var result = RequestConverter.convertRequest(request, "retrieveMultiple", _internalConfig);
1454-
1455-
// if (nextPageLink) {
1456-
// ErrorHelper.stringParameterCheck(nextPageLink, "DynamicsWebApi.retrieveMultiple", "nextPageLink");
1457-
// result.url = unescape(nextPageLink).replace(_internalConfig.webApiUrl, "");
1458-
// }
1459-
1460-
// //copy locally
1461-
// var toCount = request.count;
1462-
1463-
// return _sendRequest("GET", result.url, null, result.headers)
1464-
// .then(function (response) {
1465-
// if (response.data['@odata.nextLink'] != null) {
1466-
// response.data.oDataNextLink = response.data['@odata.nextLink'];
1467-
// }
1468-
// if (toCount) {
1469-
// response.data.oDataCount = response.data['@odata.count'] != null
1470-
// ? parseInt(response.data['@odata.count'])
1471-
// : 0;
1472-
// }
1473-
// if (response.data['@odata.context'] != null) {
1474-
// response.data.oDataContext = response.data['@odata.context'];
1475-
// }
1476-
1477-
// return response.data;
1478-
// });
1479-
//};
1462+
this.retrieveAllRequest = function (request) {
1463+
return _retrieveAllRequest(request);
1464+
};
14801465

14811466
/**
14821467
* 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
@@ -1509,6 +1494,27 @@ function DynamicsWebApi(config) {
15091494
}
15101495
}
15111496

1497+
/**
1498+
* Sends an asynchronous request to count records. Returns: Number
1499+
*
1500+
* @param {string} collection - The Name of the Entity Collection.
1501+
* @param {string} [filter] - Use the $filter system query option to set criteria for which entities will be returned.
1502+
* @param {Array} [select] - An Array representing the $select Query Option to control which attributes will be returned.
1503+
* @returns {Promise}
1504+
*/
1505+
this.countAll = function (collection, filter, select) {
1506+
return this.retrieveAllRequest({
1507+
collection: collection,
1508+
filter: filter,
1509+
select: select
1510+
})
1511+
.then(function (response) {
1512+
return response
1513+
? (response.value ? response.value.length : 0)
1514+
: 0;
1515+
});
1516+
}
1517+
15121518
/**
15131519
* Sends an asynchronous request to retrieve records.
15141520
*

dist/dynamics-web-api.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dynamics-web-api",
3-
"version": "1.2.3",
3+
"version": "1.2.4",
44
"description": "DynamicsWebApi is a Microsoft Dynamics CRM Web API helper library",
55
"keywords": [
66
"crm",

0 commit comments

Comments
 (0)