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.
-
You can do it using the ClientAPI JavaScript function formContext.getControl("<datetimefieldname>").setShowTime(true); to show the time part
-
Or formContext.getControl("<datetimefieldname>").setShowTime(false); to hide the time part
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
Post a Comment