//
you're reading...
Dynamics CRM, Dynamics CRM Master

How can we customize the Address Composite Control?


In the last post we discusses about customizing Name composite field, in this post we would discuss about Address composite field. Unlike Name composite control, Address is actually an entity in the system. The address composite control is built based on the Address entity.

Address composite control is build of Street, City, State/Province, Postal Code and Country fields.

However unlike Name composite control, the constituent fields of Address composite controls cannot be renamed from the UI. The constituent fields of the Address composite control do not appear to use the field display names, and instead appear to be hard-coded into the composite control.

The Address composite control is ONLY available for Account, Contact, Lead, Competitor, Quote, Order, and Invoice; but not available for User, Business Unit, and Site entities.

Address Flyout

Now we would explore the customization options of the Address flyout.

How to set the value of a field inside the fly-out menu?

For example, how do we default to Country to always Australia. We can do this by using a Business Rule.

Set the Country to Australia

The other way to achieve the same behavior is by adding the following Java Script code:

Xrm.Page.getAttribute(“address1_country”).setValue(“Australia”);

N.B. : When both Business Rule and Java Script is added to modify the same field, the Business Rule wins! For example, if we add a Business Rule to default the Country to “Australia” and a Java Script to default it to “USA”, the user would find the Country value to be “Australia”.

How to hide fields in the fly-out menu?

Sometimes, we want to hide a field from the address flyout like State/Province. For example, countries like UK or New Zealand does not usually use State/Province in their address.

Hide State field

To achieve the same result using a Java Script, use the following script:

Xrm.Page.getControl(“address1_stateorprovince”).setVisible(false);

How to make a field Business Required in address fly-out menu?

Making some address fields mandatory is a normal business need. Let us here try to make Street1, City, ZIP/Postal Code and Country/Region field Business Required.  Making the fields Business Required would make them mandatory in the Address flyout as well.

Mandatory Address Fields

However, we can make a field Business Required using the following Java Script code as well:

Xrm.Page.getAttribute(“address1_country”).setRequiredLevel(“required”);

How to change the label of fields in the fly-out menu?

The address fields however cannot be changed through the UI. These do not to use the field display names, and instead appear to be hard-coded into the composite control. There is no supported way to change the labels of the fields. The supported control.setLabel() Java Script API does not work as we cannot get the control of the field inside the fly-out menu.

About Dipankar Bhattacharya

Dipankar is a CITA-F, ITIL certified professional specializing Customer Relationship Management (CRM) and Cloud Computing. He is a certified Microsoft Dynamics CRM specialist and Architect and have been working in the field of CRM for enterprise customers across the globe.

Discussion

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog Stats

  • 61,049 hits

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 565 other followers

My Book

Follow me on Twitter

%d bloggers like this: