{"id":1582,"date":"2015-09-05T06:36:51","date_gmt":"2015-09-05T06:36:51","guid":{"rendered":"https:\/\/mahenderpal.wordpress.com\/?p=1582"},"modified":"2015-11-30T10:36:21","modified_gmt":"2015-11-30T10:36:21","slug":"relabeling-composite-control-fields","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=1582","title":{"rendered":"Relabeling Composite Control Fields"},"content":{"rendered":"<p>We can change display name of the entity fields easily by editing field display name property. But we can\u2019t change fields label used in address composite controls. In this post we are demonstrating how to relabel\u00a0composite control fields.<\/p>\n<p><strong>Requirement<\/strong>:Relabel city field in address composite control in account entity.<\/p>\n<p><em><strong>Note<\/strong>: You can\u2019t change field logical name once it is created.<\/em><\/p>\n<p><strong>Solution<\/strong>: We can implement this requirement using Java Script. We have option to access composite control using Java Script, we can refer them using following way:<\/p>\n<p><strong>&lt;composite control name&gt;_compositionLinkControl_&lt;constituent attribute name&gt;<\/strong><\/p>\n<p>So if we want to refer any field which is used in the composite control, We can do like following, we are accessing city field here:<\/p>\n<p><strong>&lt;composite control name&gt;<\/strong>_<strong>compositionLinkControl<\/strong>_<strong>address1_city<\/strong><\/p>\n<p>To relabel the normal fields, we can use <strong>setLabel<\/strong> method. so we can use the same method to relabel city as well. let\u2019s say we want to rename city field to \u201c<strong>Distric<\/strong>\u201d. We can use following code for that:<\/p>\n<p>Xrm.Page.getControl(&#8216;address1_composite_compositionLinkControl_address1_city&#8217;).setLabel(&#8220;District&#8221;);<\/p>\n<p>Similarly we can refer other fields as well.You can refer composite control name from the respective entity form or you can also refer it <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/dn481581.aspx\">here<\/a>.<\/p>\n<p><strong>Using\u00a0Code<\/strong>: To use this code we need to create Java Script\u00a0web resource, where we can have below method. We need to call this method on <strong>Onload<\/strong> of the account entity\u00a0form.<\/p>\n<p>function RelableAddressControl()<\/p>\n<p>{<\/p>\n<p>Xrm.Page.getControl(&#8216;address1_composite_compositionLinkControl_address1_city&#8217;).setLabel(&#8220;District&#8221;);<\/p>\n<p>}<\/p>\n<p><a href=\"https:\/\/mahenderpal.files.wordpress.com\/2015\/08\/accountform.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-1584 aligncenter\" src=\"https:\/\/mahenderpal.files.wordpress.com\/2015\/08\/accountform.png?w=300\" alt=\"accountform\" width=\"300\" height=\"199\" \/><\/a><\/p>\n<p>Now after publishing our changes, when we will open any account record we will see changes like below:<\/p>\n<p><a href=\"https:\/\/mahenderpal.files.wordpress.com\/2015\/08\/addressfield.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-1583 aligncenter\" src=\"https:\/\/mahenderpal.files.wordpress.com\/2015\/08\/addressfield.png?w=300\" alt=\"addressfield\" width=\"300\" height=\"89\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We can change display name of the entity fields easily by editing field display name property. But we can\u2019t change fields label used in address composite controls. In this post we are demonstrating how to relabel\u00a0composite control fields. Requirement:Relabel city field in address composite control in account entity. Note: You can\u2019t change field logical name once it is created. Solution:&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=1582\">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,6,8,9],"tags":[28,158,159],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1582"}],"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=1582"}],"version-history":[{"count":1,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1582\/revisions"}],"predecessor-version":[{"id":1899,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1582\/revisions\/1899"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}