Hi Guyz..I have a small requirement. I have a date field in the case form. I have to show only the next 30 days in the Calendar which when we click on that date field.
So is this requirement possible to achieve??
*This post is locked for comments
Hi,
You can not set limit to show date in Dynamics CRM , however you can set alert based on current date and clear selected value.
Below is the sample code - Hope this helps -
function myFunction() { var dateTimeValue = Xrm.Page.getAttribute("new_datetime").getValue() // "Mon May 14 2018 09:50:50 GMT-0400" - Get selected CRM Date var crmDateValue = new Date(dateTimeValue); //var eventdateTimeValue = crmDateValue.getFullYear() + '/' + (crmDateValue.getMonth() + 1) + '/' + crmDateValue.getDate(); // Uncomment Only For Date Comparison var todaydate = new Date(); //Get Current Date // var today = todaydate.getFullYear() + '/' + (todaydate.getMonth() + 1) + '/' + todaydate.getDate(); // Uncomment Only For Date Comparison if (crmDateValue <= todaydate) { //You can compare only date - using this if (eventdateTimeValue <= today) alert("event date less than equal today"); Xrm.Page.getAttribute("new_datetime").setValue(null); } else { alert("event date greater than equal today"); } }
Unfortunately, no OOB date validations exist.
As the other suggested, you would need to do a validation ONCE the user selects the date.
That's the easiest way to go about it.
Else, you would need to put your own web-resource control and have the date control. But seems to be too much of effort, unless the requirement is absolutely necessary.
Hi Muthuraman,
OOB it is not possible, instead you can write a JavaScript code on OnChange event of date field and check if user select date after 1 month then show that user a alert message.
Check if the following scripts helps
function checkdate()
{
var today = new Date();
today.setMonth(today.getMonth() +1); // add one month in current date
var fldDate = Xrm.Page.data.entity.attributes.get("fldDate").getValue()
if(fldDate.getTime() > today.getTime())
{
alert('Date can not be greater than today's date');
}
}
Hope this helps!!!
Best Regards,
Shahbaaz
Hi Muthuraman144312,
Its not possible in a supported way,
One workaround is to write the js to check the date selected falls under one month and display the message to the user.
Mohamed Amine Mahmoudi
83
Super User 2025 Season 1
Community Member
54
Victor Onyebuchi
6