Changing the Display of Multi Select fields using the Client Side API

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

Changing the Display of Multi Select fields using the Client Side API

  • Comments 5
  • Likes

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 introduced in Sage CRM 7.2.

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.

crm.ready(function () {

var myfield = crm.fields("comp_operatingcountries");
if (myfield.getMode() == "view")
re = /,/g;
myfield.text(myfield.text().replace(re, "<BR>"))

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.

  • Excellent article Jeff.

    Very very useful. I get asked this a lot

  • Thank you Jeff.  This displays the selections perfectly.

  • Hi Jeff, this realy helpful. For the first look it works. But when you would change the details from the company, then you get some HTML Code. I hope you could here also a solution.

  • Christian,

    I have corrected the code, so that it only works in view mode.  :-)

  • Many thanks for this cool work.