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

Community site session details

Session Id :

DYNAMICS 365 SHOW HIDE TIME PART OF DATETIME IN JAVASCRIPT

Charles Abi Khirs Profile Picture Charles Abi Khirs 3,569

Have you faced a situation where you wanted to conditionally show/hide the time part of a date-time field on a form?

After upgrading from D365 V8.2 to D365 V9 (9.0.16.7) on-premises, there is abnormal white space around the ribbon buttons. This behavior was everywhere whether in the views, forms or other areas.

  1. You can do it using the ClientAPI JavaScript function formContext.getControl("<datetimefieldname>").setShowTime(true); to show the time part
    show hide time part

  2. Or formContext.getControl("<datetimefieldname>").setShowTime(false); to hide the time part
    show hide time part 2

Bonus Tips:
  • In addition to setting the visibility of the time part, you can get whether the time part is shown or not using the ClientAPI function formContext.getControl("<datetimefieldname>").getShowTime();
  • This method has no effects on the fields who have the DateOnly format
  • In case of a rollup field, the time part can be also hidden using the same method. However, the Last Updated section of the rollup field cannot be hidden and will be displayed by default in the UCI


Hope This Helps!

This was originally posted here.

Comments

*This post is locked for comments