{"id":1007,"date":"2014-10-10T20:00:58","date_gmt":"2014-10-10T14:30:58","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=1007"},"modified":"2014-10-10T20:00:58","modified_gmt":"2014-10-10T14:30:58","slug":"accessing-composite-controls-programmatically-using-script","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2014\/10\/accessing-composite-controls-programmatically-using-script\/","title":{"rendered":"Accessing Composite Controls Programmatically using Script"},"content":{"rendered":"<p style=\"text-align: justify;\">You might have disabled normal controls programmatically many times but while disabling Composite Controls programmatically we get stuck. We don&#8217;t know how to access the control and going through the conventional method doesn&#8217;t yield us the expected result.<\/p>\n<p style=\"text-align: justify;\">In that case, what should\u00a0we do? How to achieve the expected result? Like this, we face many questions but we don&#8217;t get proper answer for any of these questions. What if we say the answer to these all questions is indeed very simple. Yes, the answer is very simple.<\/p>\n<p style=\"text-align: justify;\">To be truthful, even we were stuck on this, we had a requirement in which we were supposed to conditionally disable the Composite Controls as per the client from which it is accessed i.e., Web Application or Mobile. At that time even we weren&#8217;t quite sure\u00a0how to do it. But after an extensive research we found a very simple solution to our problem.<\/p>\n<p style=\"text-align: justify;\">Below piece of code will solve the mystery surrounded on how to access the Composite Controls:<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<p>(Composite control name)_compositionLinkControl_(Attribute Name)<\/p>\n<p><strong>For E.g.:<\/strong><\/p>\n<p>Xrm.Page.getControl(<span style=\"color: #993300;\">&#8220;address1_composite_compositionLinkControl_address1_city&#8221;<\/span>).setDisabled(<span style=\"color: #993300;\">true<\/span>);<\/p>\n<p>The above piece of code is to disable the City attribute of the address1 composite control.<\/p>\n<p>This way you can access all the composite fields in the CRM.<\/p>\n<p><strong>Composite attributes<\/strong><\/p>\n<p>The following table lists the composite attributes:<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"213\"><strong>Entity<\/strong><\/td>\n<td width=\"213\"><strong>Display Name<\/strong><\/td>\n<td width=\"213\"><strong>Logical name<\/strong><\/td>\n<\/tr>\n<tr>\n<td rowspan=\"3\" width=\"213\">Contact<\/td>\n<td width=\"213\">\n<table>\n<tbody>\n<tr>\n<td>Full Name<\/td>\n<td width=\"0\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<td width=\"213\">\n<table>\n<tbody>\n<tr>\n<td>fullname<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"213\"><strong>Address 1<\/strong><\/td>\n<td width=\"213\">address1_composite<\/td>\n<\/tr>\n<tr>\n<td width=\"213\"><strong>Address 2<\/strong><\/td>\n<td width=\"213\">address2_composite<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"3\" width=\"213\">Lead<\/td>\n<td width=\"213\"><strong>Full Name<\/strong><\/td>\n<td width=\"213\">Fullname<\/td>\n<\/tr>\n<tr>\n<td width=\"213\"><strong>Address 1<\/strong><\/td>\n<td width=\"213\">address1_composite<\/td>\n<\/tr>\n<tr>\n<td width=\"213\"><strong>Address 2<\/strong><\/td>\n<td width=\"213\">address2_composite<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"3\" width=\"213\">User<\/td>\n<td width=\"213\">\n<table>\n<tbody>\n<tr>\n<td>Full Name<\/td>\n<td width=\"0\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<td width=\"213\">Fullname<\/td>\n<\/tr>\n<tr>\n<td width=\"213\"><strong>Address<\/strong><\/td>\n<td width=\"213\">address1_composite<\/td>\n<\/tr>\n<tr>\n<td width=\"213\"><strong>Other Address<\/strong><\/td>\n<td width=\"213\">address2_composite<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\" width=\"213\">Account<\/td>\n<td width=\"213\"><strong>Address 1<\/strong><\/td>\n<td width=\"213\">address1_composite<\/td>\n<\/tr>\n<tr>\n<td width=\"213\"><strong>Address 2<\/strong><\/td>\n<td width=\"213\">address2_composite<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\" width=\"213\">Quote<\/td>\n<td width=\"213\">\n<table>\n<tbody>\n<tr>\n<td>Bill To Address<\/td>\n<td width=\"0\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<td width=\"213\">\n<table>\n<tbody>\n<tr>\n<td>billto_composite<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"213\"><strong>Ship To Address<\/strong><\/td>\n<td width=\"213\">shipto_composite<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\" width=\"213\">Order<\/td>\n<td width=\"213\">\n<table>\n<tbody>\n<tr>\n<td>Bill To Address<\/td>\n<td width=\"0\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<td width=\"213\">\n<table>\n<tbody>\n<tr>\n<td>billto_composite<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"213\"><strong>Ship To Address<\/strong><\/td>\n<td width=\"213\">\n<table>\n<tbody>\n<tr>\n<td>shipto_composite<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\" width=\"213\">Invoice<\/td>\n<td width=\"213\">\n<table>\n<tbody>\n<tr>\n<td>Bill To Address<\/td>\n<td width=\"0\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<td width=\"213\">billto_composite<\/td>\n<\/tr>\n<tr>\n<td width=\"213\"><strong>Ship To Address<\/strong><\/td>\n<td width=\"213\">shipto_composite<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Note:<\/strong><\/p>\n<ul>\n<li style=\"text-align: justify;\">This way you can access the Composite Controls and set values on Tablet as well. The above technique\u00a0is compatible for Tablets.<\/li>\n<li style=\"text-align: justify;\">You can access Composite Controls using the above technique\u00a0and use all the available methods like setDisabled, setVisible, setLabel, etc.<\/li>\n<li style=\"text-align: justify;\">If you want to perform any action on Composite Control as a whole then you can access it the conventional way, Xrm.Page.getControl(&#8220;address1_composite&#8221;).<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>You might have disabled normal controls programmatically many times but while disabling Composite Controls programmatically we get stuck. We don&#8217;t know how to access the control and going through the conventional method doesn&#8217;t yield us the expected result. In that case, what should\u00a0we do? How to achieve the expected result? Like this, we face many\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2014\/10\/accessing-composite-controls-programmatically-using-script\/\">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":[11,19,21,22,24,33],"tags":[311,380,1551],"class_list":["post-1007","post","type-post","status-publish","format-standard","hentry","category-controls","category-dynamics-crm","category-dynamics-crm-2013","category-dynamics-crm-2015","category-dynamics-crm-2016","category-javascript","tag-composite-control","tag-crm","tag-script"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/1007","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=1007"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/1007\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=1007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=1007"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=1007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}