Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Disable or doesn't allow to select past date

(0) ShareShare
ReportReport
Posted on by 310

Hello Sir,

My question is , How to Prevent past date selection from  date field if the date field have +3 future days followup ?

means i.e. (05/02/2019)+3days = 08/02/2019 means date field doesn't allow to select 07/02/2019 or past dates

please help

*This post is locked for comments

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,052 on at
    RE: Disable or doesn't allow to select past date

    Could you please provide more details on your requirement? If you could share screenshot and sample we might be able to help

  • Screen one Profile Picture
    Screen one 310 on at
    RE: Disable or doesn't allow to select past date

    Please share code for the same

  • Suggested answer
    shivaram Profile Picture
    shivaram 3,315 on at
    RE: Disable or doesn't allow to select past date

    Hi Manoj,

    You can only write a Javascript function and there you can get the current date + 3 days. Once you have this value, then you need to check what is updated value. If he selects which supposed to restrict, then you can clear the value and Show error message. This is the best option to achieve your requirement.Hope it helps.

    Thanks,

    Shivaram.

  • Suggested answer
    gdas Profile Picture
    gdas 50,089 on at
    RE: Disable or doesn't allow to select past date

    Manoj ,

    Try with this -

    // Register below method in onchange event 
    
    function ValidatePastDate() {
        var dateFieldVal =  Xrm.Page.getAttribute("new_dateField").getValue(); // Replace Field Name
        var dateFieldValDT = new Date(dateFieldVal);
        var dateFieldValWithFormat = dateFieldValDT.getFullYear() + '/' + (dateFieldValDT.getMonth() + 1) + '/' + dateFieldValDT.getDate(); 
        var todaydate = new Date();
        var todaywithFormat = todaydate.getFullYear() + '/' + (todaydate.getMonth() + 1) + '/' + todaydate.getDate(); 
        if (dateFieldValWithFormat < todaywithFormat) {
            alert("Selected  date less than  today");
            rm.Page.getAttribute("new_dateField").setValue(null);
        }
        else {
            alert("Selected event date greater than today");
        }
    }


  • Screen one Profile Picture
    Screen one 310 on at
    RE: Disable or doesn't allow to select past date

    How to prevent past date selection from future date , NOT from "Today's Date"

  • Screen one Profile Picture
    Screen one 310 on at
    RE: Disable or doesn't allow to select past date

    How to prevent past date selection from future date ?

  • Screen one Profile Picture
    Screen one 310 on at
    RE: Disable or doesn't allow to select past date

    But I want only future dates and if you select one  past day from that future date  then it should not be allowed in same date field

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,052 on at
    RE: Disable or doesn't allow to select past date

    Dynamics 365 calendar control cannot be configured or modified in a supported way to do what you mentioned above.

    You could have a hidden field on the form to keep the current date and set its value using a tiny js function on load of the form as shown below

    function SetCurrentDate()

    {

    Xrm.Page.getAttribute("new_todaydate").setValue(Date.now());

    }

    And you can then have a business rule on the selected date field, and if the selected value is less than the today's date field value, you can use the Set Error on the field. This will prevent the record from being saved and also the red error message on the field will force the user to select valid date.

    Hope this helps

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Disable or doesn't allow to select past date

    hi,

    you could use current date and compare with the follow up date.

    var currentdate=new Date(); //which will return current date and time object

  • Screen one Profile Picture
    Screen one 310 on at
    RE: Disable or doesn't allow to select past date

    I have only one date field & followup for +3 for same field

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 Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,321 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans