web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Start date end Date Not Working

(0) ShareShare
ReportReport
Posted on by 275

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);

}
);

}
}

I have the same question (0)
  • Matthew Lazowski Profile Picture
    3,163 on at

    Hi Ashik, could you explain without code what you want to achieve?

    There are already some validations in date fields on Project in Proj Ops in CE:

    This info may help:

    0. msdyn_taskearlieststart Task Earliest Start (TES) – used as default start date on new tasks

    1. msdyn_scheduledstart Est. Project Start Date (EPSD) – when there are no tasks, it can be set manually to any value that is before or on EPED. When there are tasks: it can be set manually to any value that is before or on EPED, it does not impact tasks nor is impacted by them.

    2. msdyn_finish Est. Project End Date (EPED)  - when there are no project tasks: can be set manually  to any value that is after or on EPSD. When there are tasks: gets calculated automatically based on end date of latest task and is non-editable.

    3. msdyn_duration Duration (Days) - when there are no tasks, gets recalculated automatically when EPDS or EPED get changed manually. When there are tasks: gets calculated automatically based on start date of earliest task and end date of latest task

    In case a project template is used to create the project, the value we set in msdyn_finish (Est. Project End Date (EPED) will be overwritten on based automatic calculations that take into account Task Earliest Start (TES), start date of earliest task and end date of latest task.

    Kind regards

    Matthew

  • Suggested answer
    Matthew Lazowski Profile Picture
    3,163 on at

    Also you need to use these APIs to work with msdyn_project entity:

    docs.microsoft.com/.../schedule-api-preview

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 467 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 420 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 241 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans