There are 2 freely available Addon
- CRM RestBuilder
- Dataverse RestBuilder
These are basically tools to create javascript webapi query and that is almost the same for Odata.
Now below code is for ajx odata query, intresting for us api call
https://mycustomer.crm.dynamics.com/api/data/v9.1/BulkDelete
and the parameters passed to it. Take a look at docs soem of the parameters are optional and we do not worry about them. Interesting for us is queryset, which hold criteria for deleteting records.
var parameters = {};
var queryset1 = {
EntityName: "account",
ColumnSet: {
AllColumns: true
},
Distinct: false,
};
queryset1["@odata.type"] = "Microsoft.Dynamics.CRM.QueryExpression";
parameters.QuerySet = [queryset1];
parameters.JobName = "";
parameters.SendEmailNotification = true;
var torecipients1 = {};
torecipients1.activitypartyid = "00000000-0000-0000-0000-000000000000"; //Delete if creating new record
torecipients1["@odata.type"] = "Microsoft.Dynamics.CRM.activityparty";
parameters.ToRecipients = [torecipients1];
var ccrecipients1 = {};
ccrecipients1.activitypartyid = "00000000-0000-0000-0000-000000000000"; //Delete if creating new record
ccrecipients1["@odata.type"] = "Microsoft.Dynamics.CRM.activityparty";
parameters.CCRecipients = [ccrecipients1];
parameters.RecurrencePattern = "";
parameters.StartDateTime = new Date("10/18/2022").toISOString();
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: Xrm.Page.context.getClientUrl() + "/api/data/v9.1/BulkDelete",
data: JSON.stringify(parameters),
beforeSend: function(XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("OData-MaxVersion", "4.0");
XMLHttpRequest.setRequestHeader("OData-Version", "4.0");
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
async: true,
success: function(data, textStatus, xhr) {
var results = data;
},
error: function(xhr, textStatus, errorThrown) {
Xrm.Utility.alertDialog(textStatus + " " + errorThrown);
}
});
Also Take a look at this answer this will guide you as well
In addition are you restricted from your webaAPI only, do you by any chance are allowed to use XRMToolBox. If yes you are numerous opportunities to perform bulk delete. Easiest will be with sql statement.