Dynamics 365 - Tip to increase user experience in multi languages projects

For those they are working on a Dynamics 365/CRM multi languages projects, you may have in the requirements to create an entity for displaying a dynamic option list the customer wants to be used in other entities, while the application can be used in multi languages, and the records created by the users in this entity cannot be translated using the localization feature in Dynamics.



It's not practical to display non relevant data to the user, or to display records names in different language they user is using.

For example,

You are using Dynamics 365 in English and Arabic, and you have a separate entity to be used as a dynamics option list in another entities records, the create form of this entity includes the name in English and in Arabic



First thing first, add to the lookup associated view, both fields, then on for load and on change of the lookup fields related to this kind of entities, in case the user is using Arabic language, you should change the label of the selected lookup records to display the Arabic name.

How we can do this?

1- Create a JavaScript web resource and add it to the form.
2- add this to the web resource created


This function will be used to retrieve records.

function getDataById(id, type, select, callback) {
    var serverUrl = Xrm.Page.context.getClientUrl();
    var oDataSelect = serverUrl + "/XRMServices/2011/OrganizationData.svc/" + type + "Set(guid'" + id + "')?$select=" + select;
    var req = new XMLHttpRequest();
    req.open("GET", oDataSelect, false);
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json;charset=utf-8");
    req.onreadystatechange = function () {
        if (req.readyState === 4) {
            if (req.status === 200) {
                callback(JSON.parse(req.responseText).d);
            }
        }
    };
    req.send();
}

The below function will be used to change the label to Arabic in case the user is using the Arabic language.

function field_onchange() {
if(Xrm.Page.context.getUserLcid() == 1025) //1025 Arabic Language code
return;
    var obj = Xrm.Page.getAttribute("form field name").getValue();
    if (obj === null) return;
    getDataById(obj[0].id, 'entity name', 'record Id field schema name,arabic field name', function(o) {
        if(!!o) Xrm.Page.getAttribute("form field name").setValue([{id: o.reccord Id field schema name, name:o.arabic field name, entityType:'entity name'}]);
    });
}

this function should run on load and on change of the lookup field.


3- Add the web resource to the form and add functions to run on certain events.
4- Save and publish.




Conclusion:

To increase the user experience, when a user is using the application in a specific language, and the labels displayed should be translated or to be displayed in the language the are using.

Happy CRMing :)

Comments

  1. Thanks for sharing such valuable information I am also impressed by the creativity of the writer. This is
    excellent information. It is amazing and wonderful to visit your site. “ why good user experience matters"

    ReplyDelete

Post a Comment

Popular Posts