Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

Setting default(constant) time in date time control

(0) ShareShare
ReportReport
Posted on by 97

Hi All,

I need to set default time 4 AM  in employee state date field in new employee form (HcmWorkerNewWorker - Form)

I have writtten code like this,but its not working,

How to set default time at 4:00:00 AM in employee state date field.

pastedimage1684137810367v1.png

Thanks in advance.

  • PJ JohnPaul Profile Picture
    PJ JohnPaul 97 on at
    RE: Setting default(constant) time in date time control

    Hi Martin,

    Thanks for your reply , as you suggested i assigned value to the datasource field, now its working fine.

  • Martin Dráb Profile Picture
    Martin Dráb 230,842 Most Valuable Professional on at
    RE: Setting default(constant) time in date time control

    You're talking about a different thing. Please look at the return value of DateTimeUtil::newDateTime(). Is it correct or not?

    It it is, but you can't assign the value to the control, we'll know that we can ignore all the other code and we need to focus on this piece only. For instance, maybe the control is bound to a data source field and you need to assign the value there. But that a speculation - the first step is to localize the problem.

  • PJ JohnPaul Profile Picture
    PJ JohnPaul 97 on at
    RE: Setting default(constant) time in date time control

    Hi Martin, 

    I am having issue in getting the value from datetimevalue(), it's having time as 12:00:00 . 

    Thanks

  • Martin Dráb Profile Picture
    Martin Dráb 230,842 Most Valuable Professional on at
    RE: Setting default(constant) time in date time control

    Let me repeat my suggestion:

    Debug your code and tell us whether you get the right datetime value from newDateTime(). That will tell you whether you have a problem with getting the value or with putting the value to the form. Then you'll know which part to debug.

  • PJ JohnPaul Profile Picture
    PJ JohnPaul 97 on at
    RE: Setting default(constant) time in date time control

    Hi Martin & Girish , 

    Thanks for your reply, sorry for the delay in response.

    In time1 variable i can get value of 14400 , whatever user selected in front end , i can get that date in date1 buffer, 
    but the issue is value for time is not set in the  employeeStartDate.dateTimeValue().Please guide me what i need to do.


    Image

    Thanks in advance.

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Setting default(constant) time in date time control

    Hi PJ John,

    Have you debugged the code. From the code what is the data value is coming in the form?

    Thanks,

    Girish S.

  • Martin Dráb Profile Picture
    Martin Dráb 230,842 Most Valuable Professional on at
    RE: Setting default(constant) time in date time control in D365FO

    Please tell us more about your problem than mere "its not working".

    Debug your code and tell us whether you get the right datetime value from newDateTime(). That will tell you whether you have a problem with getting the value or with putting the value to the form. Then you'll know which part to debug.

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…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,969 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,842 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans