I am receiving this exception from CRM while creating a recurrence as start date = current date
. Could you please help figure out what could be the possible miss.
CRM Exception Bad Request:
Series could not be created as there are no occurrences in the current recurrence definition for given range.
Some of the tags in request JSON as below:
"recurrencepatterntype": 0
starttime": "2019-05-30T10:00:00Z",
"endtime": "2019-05-30T10:30:00Z",
"patternstartdate": "2019-05-30T09:48:04Z",
"patternendtype": 2,
"occurrences": 1,
Tried to create Daily recurrence which ends after 1 occurrence and start date is current date.
I used the below code to create Recurrence rule and worked perfectly fine for me.
var entity = {};
entity.patternstartdate = new Date("05/30/2019 14:00:00").toISOString();
entity.patternenddate = new Date("05/30/2019 14:30:00").toISOString();
entity.recurrencepatterntype = 0;
entity.occurrences = 1;
entity.patternendtype = 2;
var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/recurrencerules", false);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204) {
var uri = this.getResponseHeader("OData-EntityId");
var regExp = /\(([^)]+)\)/;
var matches = regExp.exec(uri);
var newEntityId = matches[1];
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send(JSON.stringify(entity));