DYNAMICS 365 SHOW HIDE TIME PART OF DATETIME IN JAVASCRIPT

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!

Comments

Popular posts from this blog

DYNAMICS 365 HOW TO HIDE RECENT RECORDS FOR LOOKUP FIELD IN UCI

SEARCH BY GUID IN DYNAMICS 365

SAVE FORM IN DYNAMICS 365 JAVASCRIPT