Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Get Localized choice values for Dataverse record
Kinga
Kinga

Posted on

Get Localized choice values for Dataverse record

Model-driven applications offer excellent support for building multilingual applications. Translations for UI elements and entity configurations can be easily provided using an Excel file, and the application adapts to the user's selected language through the Personalization settings (seeLanguages tab options).

When accessing record information through Power Automate, choice field values are presented as numerical codes rather than their display names. To obtain the choice display names in the user's language, these numerical values must be retrieved using tools like Power Automate.

Get Localized choice values for record

The "Utils - Get Localized choice values for record" workflow retrieves definitions of choice and multi-choice fields in a Dataverse table, providing numerical values and labels for each choice in a specified language. It can be used either as a child workflow or as a standalone flow, and accepts the followingparameters:

Parameter nameDescription
Table nameThe logical name of dataverse entity, as defined inProperties / Advanced options / Logical name
lcidLCID code of a language, e.g. 1033 for English. Consider saving the language used by the user when a record is created. You may retrieve the language code using #"Invoke an HTTP request" action, calling the following endpoints:

  • https://org0api.crm17.dynamics.com/api/data/v9.2/EntityDefinitions(LogicalName='ENTITY_NAME')/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata request for single-choice, and
  • https://org0api.crm17.dynamics.com/api/data/v9.2/EntityDefinitions(LogicalName='ENTITY_NAME')/Attributes/Microsoft.Dynamics.CRM.MultiSelectPicklistAttributeMetadata request for multi-choice fields.

Important: The "HTTP with Microsoft Entra ID (preauthorized)" connector operates through a Microsoft 1st party trusted application. This application includes preauthorization for various Microsoft services and there is no need for administrators to explicitly grant consent for actions to be executed by the application on behalf of the user.
Microsoft also released a new version of the connector, the "HTTP With Microsoft Entra ID", allowing administrators to grant discrete consent.

The reason for using the "HTTP with Microsoft Entra ID (preauthorized)" connector in this workflow is to ensure it works immediately once configured, and no additional action must be executed by the administrators.

Update the workflow to use the "HTTP With Microsoft Entra ID" connector, if required.

The flowreturns the following values:

NameDescription
ResultsJSON object with the following structure:[{"LogicalName":"fieldName","Options":[{"Value":339870000,"Label":""}]}]
Error messageEmpty, if success. Otherwise error message
Success"True" or "False"

Importing solution

When importing a solution, you will need to provide a connection reference to your Power Platform Environment. Ensure that the connection is created using the URL of your Power Platform Environment.

Creating new connection

The value of "URL of the request" does not include a host name. The request URL will be created by combining the URL specified in the referenced connection with the API endpoint defined in the "URL of the request" field.

Image description

Using the flow

TheGet Localized choice values - test flow provides an example on how to use the results returned by theGet Localized choice values flow.

To speed up the retrieval of the localized label, the results from the child flow are converted into anXML object, and anxpath expression is used to quickly extract the correct value.

ThesxPathQuery variable is set to the following expression:

//arr[LogicalName="{fieldName}"]/Options[Value={fieldValue}]/Label

The{fieldName} and{fieldValue} tokens are replaced by a field logical name and a numerical value, and used in thexpath() expression, e.g.

xpath(outputs('Compose:_Json_to_Xml'), concat('string(', replace(replace(variables('sxPathQuery'), '{fieldName}', 'kk_targetgroup'), '{fieldValue}', '339870000'), ')')), or

xpath(outputs('Compose:_Json_to_Xml'), concat('string(', replace(replace(variables('sxPathQuery'), '{fieldName}', 'kk_country1'), '{fieldValue}', '756'), ')'))

When building real-life solution, you would define thefieldValues based on the record's properties.

Image description

You may download the solution with Power Automate workflow including the above examples fromPower Automate Utils GitHub repo.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.


[8]ページ先頭

©2009-2025 Movatter.jp