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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Customizing Date Field

(0) ShareShare
ReportReport
Posted on by 170

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

I have the same question (0)
  • sardar ahmed Profile Picture
    520 on at

    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.

  • Suggested answer
    Shahbaaz Ansari Profile Picture
    6,211 on at

    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

  • Suggested answer
    Shidin Haridas Profile Picture
    3,499 on at

    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.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

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


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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
RichardM Profile Picture

RichardM 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans