If you use two languages in your CRM instance, you may need to show the MS CRM lookup language that matches the current user: for example, product names in English for one user and in Russian for another. Standard functionality does not provide this feature, so we need a custom plugin.

How the MS CRM lookup language solution works

The idea is to add extra fields to the entity, one field per language. When a record is saved, the plugin concatenates all translations into the standard primary attribute. When CRM runs the Retrieve or RetrieveMultiple methods, the plugin parses that value and keeps only the text in the user’s language.

Preparing the Product entity

Let’s look at an example with Products. First, prepare the entity:

  • Add the attributes new_name_en and new_name_ru to the Product entity (English and Russian must both be enabled in your organization).
  • When a product is created or updated, all language versions are concatenated into the Name field. Each time Name is requested, the plugin parses it, finds the name in the required language and writes it back into Name. For this reason, extend the length of the Name field to 4000 characters.

Plugin structure

The plugin contains seven functions: five working functions and two helpers. The working functions are registered for different events and entities and do the packing and parsing. The helper functions detect the language of the current user and read attribute values from the entity.

Registering the MS CRM lookup language plugin

Register the following steps with the Plugin Registration Tool:

  • PackNameTranslations: events Create and Update, pre-stage, entity product. Packs all translations into Name.
  • UnpackNameOnRetrieve: event Retrieve, post-stage, entity product. Returns the name in the user’s language when one record is opened.
  • UnpackNameOnRetrieveMultiple: event RetrieveMultiple, post-stage, entity product. Does the same for lists, views and lookups.
  • UnpackNameOnRetrieveRelated: event Retrieve, post-stage, entity opportunityproduct.
  • UnpackNameOnRetrieveMultipleRelated: event RetrieveMultiple, post-stage, entity opportunityproduct.

After that, lookups, forms and views show product names in each user’s own language. The same approach works for any entity whose primary attribute needs translations. Learn more about plugin events in the Dataverse event framework documentation, the modern successor of the CRM plugin model.

Read also: how to display only active records in MS CRM 4.0 extended search lookup.