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

Notifications

Announcements

No record found.

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
    69 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
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 171 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 83

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans