Search code examples
dynamics-crmliquidmicrosoft-dynamicsfetchxmldynamics-crm-portals

FetchXML Localization


I have a FetchXML Query that returns the correct entities for my portal.

How do I get the translated values stored in my CRM

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
    <entity name="testentity">
        <attribute name="xyz_testclassification" />
        <attribute name="xyz_schemaname" />
    </entity>
</fetch>

Solution

  • Working with XML and assuming attribute "xyz_testclassification" is an option set type your FetchXML query could return a resultset like this:

    <resultset morerecords="0">
      <result>
        <xyz_testclassification name="Option One" formattedvalue="10003">10003</xyz_testclassification><xyz_schemaname>One</xyz_schemaname>
      </result>
      <result />
      <result>
        <xyz_testclassification name="Option Two" formattedvalue="10004">10004</xyz_testclassification><xyz_schemaname>Two</xyz_schemaname>
      </result>
      <result>
        <xyz_testclassification name="Option Three" formattedvalue="10001">10001</xyz_testclassification><xyz_schemaname>Three</xyz_schemaname>
      </result>
    </resultset>
    

    Here XML attribute "name" contains the display name of the option value. Attribute "formattedvalue" is only useful for numeric attributes (int, decimal, double, money).

    When you are using FetchXML in C#, method IOrganizationService.RetrieveMultiple will return Entity objects. The Entity class has a FormattedValues collection containing the display values.

    All values are returned according to the language and formatting settings of the user on behalf of whom the system is queried.