{"id":2717,"date":"2016-05-04T16:17:08","date_gmt":"2016-05-04T10:47:08","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=2717"},"modified":"2022-07-19T16:51:32","modified_gmt":"2022-07-19T11:21:32","slug":"set-value-for-date-only-field-using-web-api-in-dynamics-crm-2016","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2016\/05\/set-value-for-date-only-field-using-web-api-in-dynamics-crm-2016\/","title":{"rendered":"Set value for Date only field using Web API in Dynamics CRM 2016"},"content":{"rendered":"<p style=\"text-align: justify;\"><strong>Introduction:<\/strong><\/p>\n<p style=\"text-align: justify;\">In one of our previous <a href=\"https:\/\/www.inogic.com\/blog\/2016\/02\/set-values-of-all-data-types-using-web-api-in-dynamics-crm\/\" target=\"_blank\" rel=\"noopener noreferrer\">blog<\/a> we have shown how to set attribute values for different data types using Web API for JavaScript.<\/p>\n<p style=\"text-align: justify;\">There is an exception that we are not able to set value for <strong>Date only<\/strong> field having behavior <strong>Date only<\/strong> in conventional way by assigning date object to the attribute as it will give you below error.<a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2016\/05\/Set-value-for-Date-only-field.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-2720\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2016\/05\/Set-value-for-Date-only-field.png\" alt=\"Set value for Date only field\" width=\"446\" height=\"159\" \/><\/a><\/p>\n<p>Even if we provide date in EDM format as shown below, issue still persist.<a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2016\/05\/Set-value-for-Date-only-field-using-Web-API.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-2719\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2016\/05\/Set-value-for-Date-only-field-using-Web-API.png\" alt=\"Set value for Date only field using Web API\" width=\"353\" height=\"97\" \/><\/a><\/p>\n<p>So we did research for the same and come across below work around to set value for <strong>Date only<\/strong> field having behavior <strong>Date only<\/strong>.<a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2016\/05\/Set-value-for-Date-only-field-using-web-api-crm.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-2718\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2016\/05\/Set-value-for-Date-only-field-using-web-api-crm.png\" alt=\"Set value for Date only field using web api - crm\" width=\"383\" height=\"107\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">You need to provide value for the field in \u201cYYYY-mm-dd\u201d format which will work. In above example we have checked for OOB Birthdate field for contact which is date only field.<\/p>\n<p style=\"text-align: justify;\"><strong>Conclusion<\/strong>:<\/p>\n<p style=\"text-align: justify;\">If we want to set value for date time filed from CRM having behavior Date only using Web API, we have to pass date in \u201cYYYY-mm-dd\u201d format.<\/p>\n<h2 style=\"text-align: left;\"><div class=\"su-heading su-heading-style-default su-heading-align-center\" id=\"\" style=\"font-size:15px;margin-bottom:5px\"><div class=\"su-heading-inner\">70% of global 2000 companies apply gamification to improve productivity and returns!<\/div><\/div><\/h2>\n<p><em><strong><a href=\"https:\/\/bit.ly\/3RD4lYW\" target=\"_blank\" rel=\"noopener noreferrer\">Gamifics365<\/a> <\/strong>\u2013 Spin the magic of games within Microsoft Dynamics 365 CRM to improve user adoption, enhance productivity, and achieve company goals!<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: In one of our previous blog we have shown how to set attribute values for different data types using Web API for JavaScript. There is an exception that we are not able to set value for Date only field having behavior Date only in conventional way by assigning date object to the attribute as\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2016\/05\/set-value-for-date-only-field-using-web-api-in-dynamics-crm-2016\/\">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":[16,24,65],"tags":[1597,1825],"class_list":["post-2717","post","type-post","status-publish","format-standard","hentry","category-dynamics-365","category-dynamics-crm-2016","category-webapi","tag-set-value-for-date-only","tag-web-api-in-dynamics-crm"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/2717","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=2717"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/2717\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=2717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=2717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=2717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}