Hello Team,
I m facing issue in Start date End date Validation below of my code and here le(Less then equal) and ge (grater then equal) not working
function projectFilterbasedonDate(executionContext) {
if (Xrm.Page.getAttribute('msdyn_project').getValue() != null) {
var formContext = executionContext.getFormContext();
var userSettings = Xrm.Utility.getGlobalContext().userSettings;
var date = Xrm.Page.getAttribute('msdyn_date').getValue();
var year = date.getFullYear() + "";
var month = (date.getMonth() + 1) + "";
var day = date.getDate() + "";
var dateOnly = year + "-" + month + "-" + day;
var resource = Xrm.Page.context.getUserName();
var UserId = Xrm.Page.context.getUserId();
var notificationTime = 5000;
var ERRORID = "ERROR";
var project = Xrm.Page.data.entity.attributes.get("msdyn_project").getValue()[0].id;
var projectName = Xrm.Page.data.entity.attributes.get("msdyn_project").getValue()[0].name;
project = project.replace('{', '');
project = project.replace('}', '');
UserId = UserId.replace('{', '');
UserId = UserId.replace('}', '');
Xrm.WebApi.online.retrieveMultipleRecords("bookableresource", "?$select=_userid_value&$filter=_userid_value eq " + UserId + "").then(
function success(result) {
if (result.entities.length > 0) {
var bookableresource = result.entities[0];
var bookableresourceid = bookableresource["bookableresourceid"];
Xrm.WebApi.online.retrieveMultipleRecords("msdyn_projectteam", "?$select=msdyn_start,msdyn_finish,_msdyn_bookableresourceid_value,_msdyn_project_value&$filter=_msdyn_project_value eq " + project + " and _msdyn_bookableresourceid_value eq " + bookableresourceid + " and msdyn_start le " + dateOnly + " and msdyn_finish ge " + dateOnly + "").then(
function success(result) {
if (result.entities.length > 0) {
} else {
Xrm.Page.getAttribute('msdyn_project').setValue(null);
formContext.ui.setFormNotification("Select project as per valid date", "ERROR", ERRORID);
setTimeout(
function() {
formContext.ui.clearFormNotification(ERRORID);
},
notificationTime
);
}
}
);
}
},
function(error) {
Xrm.Utility.alertDialog(error.message);
}
);
}
}