Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

AEM Forms drop-down list localization

Avatar

Avatar
Validate 1
Level 1
idekaresearch
Level 1

Likes

0 likes

Total Posts

7 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
idekaresearch
Level 1

Likes

0 likes

Total Posts

7 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile
idekaresearch
Level 1

04-11-2019

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]?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 1
idekaresearch
Level 1

Likes

0 likes

Total Posts

7 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
idekaresearch
Level 1

Likes

0 likes

Total Posts

7 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile
idekaresearch
Level 1

04-11-2019

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);

------------------------------------------------------------------------------------------

Answers (3)

Answers (3)

Avatar

Avatar
Validate 1
Level 10
Mayank_Gandhi
Level 10

Likes

284 likes

Total Posts

1,105 posts

Correct Reply

182 solutions
Top badges earned
Validate 1
Contributor 2
Ignite 5
Ignite 3
Ignite 10
View profile

Avatar
Validate 1
Level 10
Mayank_Gandhi
Level 10

Likes

284 likes

Total Posts

1,105 posts

Correct Reply

182 solutions
Top badges earned
Validate 1
Contributor 2
Ignite 5
Ignite 3
Ignite 10
View profile
Mayank_Gandhi
Level 10

04-11-2019

Yes, the approach you are using is fine. Just place the script on the value-commit of the language field.

Avatar

Avatar
Validate 1
Level 1
idekaresearch
Level 1

Likes

0 likes

Total Posts

7 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
idekaresearch
Level 1

Likes

0 likes

Total Posts

7 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile
idekaresearch
Level 1

04-11-2019

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);

}

Avatar

Avatar
Validate 1
Level 10
Mayank_Gandhi
Level 10

Likes

284 likes

Total Posts

1,105 posts

Correct Reply

182 solutions
Top badges earned
Validate 1
Contributor 2
Ignite 5
Ignite 3
Ignite 10
View profile

Avatar
Validate 1
Level 10
Mayank_Gandhi
Level 10

Likes

284 likes

Total Posts

1,105 posts

Correct Reply

182 solutions
Top badges earned
Validate 1
Contributor 2
Ignite 5
Ignite 3
Ignite 10
View profile
Mayank_Gandhi
Level 10

04-11-2019

Hi,

Do you need to make 2 different calls to get the different language list?