Skip to main content

Notifications

Customer Service forum

Setting a value to a custom date field

Posted on by 40

Hi there, I've created a form with a date field (Reporting End Date) which is tied to a custom entity. I want that value to default to the last day of the current month. I can't figure out how to accomplish this using the business rules or by creating a calculated value field. Can someone please help?

Thanks in advance!

  • Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Setting a value to a custom date field

    Hi,

    Please mark my answer as verified if that helped you. Thanks XD

  • sunnz Profile Picture
    sunnz 40 on at
    RE: Setting a value to a custom date field

    Thanks for the help!

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Setting a value to a custom date field

    Hi,

    use below options, i don't think business rule is able to achieve that.

    Javascript

    - var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);

    [View:https://www.tutorialspoint.com/How-to-get-first-and-last-date-of-the-current-month-with-JavaScript:750:50]

    C#

    stackoverflow.com/.../getting-first-and-last-day-of-the-current-month

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,902 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,297 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans