Skip to content

v1.6.0

Compare
Choose a tag to compare
@AleksandrRogov AleksandrRogov released this 23 Nov 21:02

Changes:

  • Parse response of a failed batch request. Important! This is a breaking change for those who use batch requests because of changes in an error parameter type which is passed in the catch callback. Starting from v1.6.0 a parameter passed inside a catch callback of a failed batch request is an array of objects, one of those objects is the error that caused the batch to fail. Usually it is at the same index as a failed request in the batch. To get an error message, I would recommend looping though an array and checking the type of each object, for example: response[i] instanceof Error.
dynamicsWebApi.startBatch();

dynamicsWebApi.retrieveMultiple('accounts');
dynamicsWebApi.update('00000000-0000-0000-0000-000000000002', 'contacts', { firstname: "Test", lastname: "Batch!" });
dynamicsWebApi.retrieveMultiple('contacts');

//execute a batch request:
dynamicsWebApi.executeBatch()
    .then(function (responses) {
       //parse response
    }).catch(function (response) {
        //response is an array
        for (var i = 0; i < response.length; i++){
            if (response[i] instanceof Error){
                //error will be at the same index as the failed request in the batch
            }
            else{
                //response of a successful request
            }
        }
    });