Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Populate Date and Time field with current system time on click of field

Posted on by 12

Hi,

I have a requirement where a custom Date and Time field needs to be populated with the current user date and time on click of the field instead of user manually selecting the date and time. 

Using Calculated field with Action Now() leads to the field being populated on form load and that is not what I'm looking for as the field on click triggers a different function. Is there any way I can achieve this? 

Any help is appreciated

Thanks,

Rupal

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Populate Date and Time field with current system time on click of field

    Hi partner,

    You can also try using workflow or js to populate date time automatically.

    1.workflow.

    Create an on-demand workflow and populate date field with dynamics value--Execution Time.

    pastedimage1601262537415v1.png

    pastedimage1601262564240v2.png

    2.Js.

    function updateDateField(executionContext) {
       var formContext = executionContext.getFormContext();
       var date = formContext.getAttribute("new_date");
       var currentDateTime = new Date();
       date.setValue(currentDateTime);
    }

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Populate Date and Time field with current system time on click of field

    Hi,

    You mean when Calculated field populate your field value then on change event does not trigger which cause javascript associated to onchange on that filed not gets executed. Correct?

    Can you try using Business Rule to set current date and time instead of using Calculated field.

    Please mark my answer verified if i were helpful

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans