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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Adding a year field drop down list - year only field

(0) ShareShare
ReportReport
Posted on by

Hi,

i have to add a company established date field in CRM form with the following requirement. 

Year will be a 4 digit number drop-down list.
Any number is acceptable up to the current year.
How i can add a field to display upto the current year?
thank you, Siva
I have the same question (0)
  • Nya Profile Picture
    29,060 on at

    Hi Siva,

    Would you please indicate whether you need to insert the Year field into an entity's Main form or a Marketing Form?

     

    Best Regards,

    Nya

  • SivaR Profile Picture
    71 on at

    Yes, i have to include the year field in the Entity's main form and save the value.

    Thank you,

    Siva

  • Suggested answer
    Georgios Balafoutis Profile Picture
    Microsoft Employee on at

    Hi Siva,

    You can find a a step-by-step guide to add events listeners and validation here: www.languagetechfunda.com/.../validate-end-date-greater-start-date-dynamics-crm

    If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well. 

    Thank you. 

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Siva,

    You can use regex validation for year to address here are some of the links which may be helpful to you.

    1. https://www.regextester.com/93651

    2. https://www.py4u.net/discuss/340793

    3. https://stackoverflow.com/questions/17547710/javascript-regex-validate-years-in-range

    If you can get exact regex using above link then you can just check with Regex.Match to address your requirement.

    If not then you can perform below operation-

    1. Check Regex.Match with 4 digit number ^[12][0-9]{3}$ ( Validate from 1000 - 2999)

    2. After above regex check you can validate it with current year using -> new Date().getFullYear()

    3. Code will be some how as below,

    function Year_Validation(input)
    {
      var Year = /^[12][0-9]{3}$/;
      if((input.value.match(year))
            {
    currentYear =
    new Date().getFullYear();

    if(currentYear <= input){
            // Perform Operation
    }
    } else { alert("This is not a valid year"); } }

    Hope this help you, If it is helpful pls mark as Verified Answer, which will help others as well. Thanks!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 189 Super User 2026 Season 1

#2
CU11031447-0 Profile Picture

CU11031447-0 100

#3
NeerajPawar Profile Picture

NeerajPawar 66

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans