Hello,
I'm supposed to create a JS-Ribbon-Button that deletes a ton of records. Since there is no Xrm.WebApi.deleteMultiple() method, I tried doing it with executeMultiple.
Request object code is:
deleteRequest = function (entityName, recordId) {
this.EntityName = entityName;
this.RecordId = { "guid": recordId };
this.getMetadata = function() {
return {
boundParameter: undefined,
operationName: 'Delete',
operationType: 2,
parameterTypes: {
'EntityName': {
'typeName': "Edm.String",
'structuralProperty': 1
},
'RecordId': {
'typeName': "Edm.Guid",
'structuralProperty': 1
}
}
}
}
}
For testing purposes I was using static values and creating an array of request objects from that:
async function deleteMultipleRecords() {
try {
let reqObj1 = new deleteRequest('invoice', '4842dec3-84c9-e911-a839-000d3ab18d29')
let reqObj2 = new deleteRequest('invoice', 'c552f5c3-84c9-e911-a833-000d3ab182a9')
let reqObjArr = [reqObj1, reqObj2]
res = await Xrm.WebApi.online.executeMultiple(reqObjArr)
console.log(res)
} catch (error) {
console.log(`${error.name}: ${error.message}`)
}
}
}
I am getting a not very helpful error in console:
An error has occured. Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solutions or contact your organization's Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support.
My request object must be wrong, but I don't see how? Anyone know where I made a mistake? I would really appreciate the help.