This article has been prompted by a customer who had a requirement to change the default display of a multiselect field. This article uses the Client Side API.
The default display of a field is shown below.
The default display shows the data in a comma seperated list. The customer instead need to have the values of the multiselect shown in a vertical list, like in the image below:
To change the display needed a little bit of code that changed the HTML that was rendered. This code was added to the custom content box of the screen, which in this example is the companyboxlong.
<script>
crm.ready(function () {
var myfield = crm.fields("comp_operatingcountries");
if (myfield.getMode() == "view")
{
re = /,/g;
myfield.text(myfield.text().replace(re, "<BR>"))
}
})
</script>
Note: A regular expression has been used in the search and replace that changes the HTML to include the <BR> tags. The target field is called comp_operatingcountries.