Skip to main content

Notifications

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

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Customizing Date Field

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


  • Suggested answer
    Shidin Haridas Profile Picture
    3,497 on at
    RE: Customizing Date Field

    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
    Shahbaaz Ansari Profile Picture
    6,211 on at
    RE: Customizing Date Field

    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

  • sardar ahmed Profile Picture
    520 on at
    RE: Customizing Date Field

    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.

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans