{"id":490,"date":"2011-07-01T06:33:35","date_gmt":"2011-07-01T06:33:35","guid":{"rendered":"http:\/\/mahenderpal.wordpress.com\/?p=490"},"modified":"2011-07-01T06:33:35","modified_gmt":"2011-07-01T06:33:35","slug":"close-ms-crm-2011-form-using-js","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=490","title":{"rendered":"Close MS CRM 2011 Form using JS"},"content":{"rendered":"<p>Some time we need to validate based on their input values and need to close crm form if they are not validated, we can do this validation through plugin but, we can\u2019t close form through plugin. So Javascript comes in picture here. We can do this through JS code. To close ms crm form we have close method available, we can use it like below<\/p>\n<p><strong>Xrm.Page.ui.close();<\/strong><\/p>\n<p>But if you will use this statement, you will get a prompt like below<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-491\" title=\"Prompt\" src=\"http:\/\/mahenderpal.files.wordpress.com\/2011\/07\/prompt.png?w=300\" alt=\"\" width=\"300\" height=\"180\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>to stop this prompt you need to use <strong><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/gg334409.aspx#BKMK_getSubmitMode\">getSubmitMode<\/a><\/strong> method of attribute and need to set\u00a0submitMode to never like below<\/p>\n<p>\u00a0var attributes = Xrm.Page.data.entity.attributes.get();<\/p>\n<p>\u00a0 for (var i in attributes)<\/p>\n<p>\u00a0\u00a0\u00a0 {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 attributes[i].setSubmitMode(&#8220;never&#8221;); }<\/p>\n<p>Xrm.Page.ui.close();<\/p>\n<p>&nbsp;<\/p>\n<p>Hope it will help somebody!!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some time we need to validate based on their input values and need to close crm form if they are not validated, we can do this validation through plugin but, we can\u2019t close form through plugin. So Javascript comes in picture here. We can do this through JS code. To close ms crm form we have close method available, we&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=490\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/490"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=490"}],"version-history":[{"count":0,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/490\/revisions"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}