Problem
One of the latest features of Dynamics 365 Portals is the multi-language portal capability. When I tried to create a new Website Language record, I faced an issue where, I couldn’t see any of Portal Language records to select in the lookup.
To investigate further, I ran an Advanced Find query to get a list of Portal Language records.
Clearly, the data are there but for some reason the lookup doesn’t show the Portal Languages list.
Resolution
I suspected, there should be a script to filter the lookup field’s results list. I opened the Form Editor to edit the Website Language form. Opened the Form Properties and I noticed there’s a JavaScript function configured to run onLoad of the form.
Library: adx.multilanguage/adx.website.js
Function: adx.multilanguage.website.onWebsiteLanguageLoad
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
function onWebsiteLanguageLoad() { resolve(scriptDependencies, function () { preSearchPortalLanguage(); var formType = Xrm.Page.ui.getFormType(); if (formType === 2) { //Edit Mode disableControls(["adx_name", "adx_websiteid", "adx_portallanguageid"]); return; } else if (formType === 1) { //Create Mode disableControls(["adx_name", "adx_websiteid"]); updatePublishingState(); } getInvalidMessageFromResource(); }); } |
This function (onWebsiteLanguageLoad) calls another function (preSearchPortalLanguage) which configures the custom filter.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
function preSearchPortalLanguage() { var control = Xrm.Page.getControl("adx_portallanguageid"); control.addPreSearch(function () { var filter = ""; var websiteLanguages = getExistingWebsiteLanguages(); if (websiteLanguages) { var languages = websiteLanguages.entities; if (languages && languages.length > 0) { var portalLanguagesConditions = ""; for (var i = 0; i < languages.length; i++) { var languageId = languages[i].attributes.adx_portallanguageid.id; portalLanguagesConditions += "<condition attribute=\"adx_portallanguageid\" operator=\"neq\" value=\"" + languageId + "\"/>"; } filter += "<filter type=\"and\">" + portalLanguagesConditions + "</filter>"; } } availableLanguages = getAvailableCrmLanguages(); if (availableLanguages && availableLanguages.length > 0) { var availableLanguagesConditions = ""; for (var i = 0; i < availableLanguages.length; i++) { availableLanguagesConditions += "<condition attribute=\"adx_systemlanguage\" operator=\"eq\" value=\"" + availableLanguages[i].value + "\"/>"; } filter += "<filter type=\"or\">" + availableLanguagesConditions + "</filter>"; } if (filter) control.addCustomFilter(filter); }); } |
I disabled the script temporarily. Saved and Published.
Now you can see the Portal Language list.
Thank you for visiting Dyn365Apps.com.
Follow me on Twitter to get the latest news, tips and tricks and more …
Until next time…