web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

[Tip] Dynamics 365 Portals – Multi-Language Portal Configuration Issue

Nadeeja Bomiriya Profile Picture Nadeeja Bomiriya 6,804

Bug in Multi Languages Configuration

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.

No Portal Language Record Found

To investigate further, I ran an Advanced Find query to get a list of Portal Language records.

Advanced Find - Portal Languages

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

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.

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.

Disable JavaScript Function

Now you can see the Portal Language list.

Select Portal Language Record

Thank you for visiting Dyn365Apps.com.

Follow me on Twitter to get the latest news, tips and tricks and more …

Until next time…

Comments

*This post is locked for comments