I am binding a drop-down list to an Entity in MS Dynamics. The data is just reference look-up data. I need to fetch either the English or French data from the Entity based on the language the user selects in the User Interface. e.g. list of countries in either English or French
In the Forms editor, when binding a drop-down list to REST endpoint, the Display Value must be selected from the list of available fields from the endpoint. This basically hard-codes the returned values to just a single language.
How can I set the Display Value based on the the language the user selects in the User Interface [not the browser language setting]?
Solved! Go to Solution.
Views
Replies
Total Likes
Here is the final code hat works in the drop-down list initialization:
------------------------------------------------------------------------------------------
var operationInfo = {
"formDataModelId": "/content/dam/formsanddocuments-fdm/ms-dynamics-fdm",
"operationTitle": "GET salutation /salutations",
"operationName": "GET salutation /salutations_15592508761020"
};
var inputs = {
};
var outputs;
var str = window.location.href.toLowerCase();
var matches = str.match(/afacceptlang=([^&]*)/); // extract query string parameter
if ( (matches !== null) && ( matches[1].toLowerCase() == 'fr' ) ) {
console.log('FRENCH');
outputs={
savedValue:'salutationid',
displayedValue:'namefra',
field:this
};
}
else { // default language
console.log('ENGLISH');
outputs={
savedValue:'salutationid',
displayedValue:'name',
field:this
};
}
guidelib.dataIntegrationUtils.setOptionsFromService(operationInfo, inputs, outputs);
------------------------------------------------------------------------------------------
Views
Replies
Total Likes
Hi,
Do you need to make 2 different calls to get the different language list?
Views
Replies
Total Likes
I use the Visual Editor to bind the list once.
Seems like the below should work in the Code Editor data-binding
if(languageParameter='en') {
var operationInfo = {
"formDataModelId": "/content/dam/formsanddocuments-fdm/ms-dynamics-fdm",
"operationTitle": "GET salutation /salutations",
"operationName": "GET salutation /salutations_15592508761020"
};
var inputs = {
};
var outputs={
savedValue:'salutationid',
displayedValue:'name_en',
field:this
};
guidelib.dataIntegrationUtils.setOptionsFromService(operationInfo, inputs, outputs);
}
else {
var operationInfo = {
"formDataModelId": "/content/dam/formsanddocuments-fdm/ms-dynamics-fdm",
"operationTitle": "GET salutation /salutations",
"operationName": "GET salutation /salutations_15592508761020"
};
var inputs = {
};
var outputs={
savedValue:'salutationid',
displayedValue:'name_fr',
field:this
};
guidelib.dataIntegrationUtils.setOptionsFromService(operationInfo, inputs, outputs);
}
Views
Replies
Total Likes
Yes, the approach you are using is fine. Just place the script on the value-commit of the language field.
Views
Replies
Total Likes
Here is the final code hat works in the drop-down list initialization:
------------------------------------------------------------------------------------------
var operationInfo = {
"formDataModelId": "/content/dam/formsanddocuments-fdm/ms-dynamics-fdm",
"operationTitle": "GET salutation /salutations",
"operationName": "GET salutation /salutations_15592508761020"
};
var inputs = {
};
var outputs;
var str = window.location.href.toLowerCase();
var matches = str.match(/afacceptlang=([^&]*)/); // extract query string parameter
if ( (matches !== null) && ( matches[1].toLowerCase() == 'fr' ) ) {
console.log('FRENCH');
outputs={
savedValue:'salutationid',
displayedValue:'namefra',
field:this
};
}
else { // default language
console.log('ENGLISH');
outputs={
savedValue:'salutationid',
displayedValue:'name',
field:this
};
}
guidelib.dataIntegrationUtils.setOptionsFromService(operationInfo, inputs, outputs);
------------------------------------------------------------------------------------------
Views
Replies
Total Likes