{"id":27928,"date":"2021-05-17T13:05:34","date_gmt":"2021-05-17T13:05:34","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=27928"},"modified":"2021-09-01T10:45:18","modified_gmt":"2021-09-01T10:45:18","slug":"how-to-show-or-hide-the-time-part-of-datetime-column-using-client-api-in-model-driven-app","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2021\/05\/how-to-show-or-hide-the-time-part-of-datetime-column-using-client-api-in-model-driven-app\/","title":{"rendered":"How to Show or Hide the Time Part of DateTime Column using client API in Model-driven app"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p style=\"text-align: justify;\">As we know in the latest release Microsoft has introduced many new features in the Client API. There are number of client APIs provided by Microsoft that help developers work seamlessly with Dynamics 365 CRM. In this blog, we will explore one of the Client API to Show or Hide the Time part of the Date Time control.<\/p>\n<p><strong>Scenario:<\/strong><\/p>\n<p style=\"text-align: justify;\">Suppose, there is a datetime type of field\/column and two different forms. Now, the user wants to show Date and Time on FORM1, and on FORM 2, the user only wants to show Date. So in this case, we can use the Client API to show\/hide the time part of the DateTime field by using <strong>getShowTime<\/strong> and <strong>setShowTime<\/strong> functions.<\/p>\n<p style=\"text-align: justify;\">We have created a new datetime field named as \u2018Date Shipped\u2019 which will display the date and time on the form as shown below. Now, let\u2019s explore both (<strong>setShowTime, getShowTime<\/strong> ) functions here.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/05\/1-Show-or-Hide-Time-Part-of-Date-Time-Column-using-client-Api-1.jpeg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-27929\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/05\/1-Show-or-Hide-Time-Part-of-Date-Time-Column-using-client-Api-1.jpeg\" alt=\"Show or Hide Time Part of Date Time Column using client Api\" width=\"755\" height=\"376\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/05\/1-Show-or-Hide-Time-Part-of-Date-Time-Column-using-client-Api-1.jpeg 755w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/05\/1-Show-or-Hide-Time-Part-of-Date-Time-Column-using-client-Api-1-300x149.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/05\/1-Show-or-Hide-Time-Part-of-Date-Time-Column-using-client-Api-1-660x329.jpeg 660w\" sizes=\"(max-width: 755px) 100vw, 755px\" \/><\/a><\/p>\n<p><strong>1. setShowTime():<\/strong><\/p>\n<p style=\"text-align: justify;\">This function will help to show\/hide the time part of the DateTime field in the FORM. Basically, you need to pass false in function parameter to hide the time.<\/p>\n<p style=\"text-align: justify;\"><strong>Example:<\/strong> formContext.getControl(\u201cnew_dateshipped\u201d).setShowTime(false);<\/p>\n<p style=\"text-align: justify;\">As you can see in the below screen shot, the time part is hidden.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/05\/2-Show-or-Hide-the-Time-Part-of-Date-Time-Column-using-client-Api-1.jpeg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-27930\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/05\/2-Show-or-Hide-the-Time-Part-of-Date-Time-Column-using-client-Api-1.jpeg\" alt=\"Show or Hide Time Part of Date Time Column using client Api\" width=\"754\" height=\"358\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/05\/2-Show-or-Hide-the-Time-Part-of-Date-Time-Column-using-client-Api-1.jpeg 754w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/05\/2-Show-or-Hide-the-Time-Part-of-Date-Time-Column-using-client-Api-1-300x142.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/05\/2-Show-or-Hide-the-Time-Part-of-Date-Time-Column-using-client-Api-1-660x313.jpeg 660w\" sizes=\"(max-width: 754px) 100vw, 754px\" \/><\/a><\/p>\n<p><strong>2. getShowTime() :<\/strong><\/p>\n<p style=\"text-align: justify;\">It checks whether the date control shows the time portion of the datetime column or not. It returns true if it shows the time portion of the date and false if not shown. So, basically, it will help to identify whether the datetime field is showing time or not.<\/p>\n<p><strong>Example:<\/strong> formContext.getControl(\u201cnew_dateshipped\u201d).getShowTime();<\/p>\n<p><strong>Note:<\/strong> This method does not work when the DateOnly format is used.<\/p>\n<h2>Conclusion<\/h2>\n<p style=\"text-align: justify;\">With this method, you can show or hide the time component of a date control where the attribute uses the <strong>DateAndTime<\/strong> format.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/product\/integrations\/inolink-quickbooks-microsoft-dynamics-crm\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-27931 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/05\/inolink.jpg\" alt=\"\" width=\"800\" height=\"200\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/05\/inolink.jpg 800w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/05\/inolink-300x75.jpg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/05\/inolink-768x192.jpg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/05\/inolink-660x165.jpg 660w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction As we know in the latest release Microsoft has introduced many new features in the Client API. There are number of client APIs provided by Microsoft that help developers work seamlessly with Dynamics 365 CRM. In this blog, we will explore one of the Client API to Show or Hide the Time part of\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2021\/05\/how-to-show-or-hide-the-time-part-of-datetime-column-using-client-api-in-model-driven-app\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[1979,1194],"class_list":["post-27928","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-client-api","tag-model-driven-app"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/27928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=27928"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/27928\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=27928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=27928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=27928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}