We will learn & understand the use of String (RESX) web resources in Dynamics 365. Before we start, make sure to subscribe to CRM Crate so that you can stay up to date in the field of Dynamics 365.
What are RESX files?
The .Net Resource (.resx) files are a monolingual file format used in Microsoft .Net Applications. The RESX or Resource Files are used by programs developed with Microsoft’s .NET Framework, itstores objects and strings for a program in an XML format. RESX file may contain both plain text information as well as binary data, which is encoded as text within the XML tags.
How to create a RESX file?
Step 1 – Open the Visual Studio IDE.
Step 2 – Create a new Resource File as shown below.
Step 3 – Create your own Key Value pair in the RESC file.
Note: – In our case, we have created a key value pair for describing the language translation where the key describes the English language word and the value describes its Marathi language equivalent word as shown below.
Step 4 – Save the RESX file in your local system.
Using RESX file in Dynamics 365
We will retrieve & use the above created RESX file in Dynamics 365 with help of client side scribe and Microsoft web APIs.
Client API for accessing RESX file –
We will use the getResourceString client API for consuming the RESX file data.
Xrm.Utility.getResourceString(webResourceName,key)Returns the localized string for a given key associated with the specified web resource.
Use Case for demonstration –
- For demonstration purpose, we will use the RESX file for achieving the English language to Marathi language text translation in Dynamics 365.
- The user will enter a English text as an input in Dynamics 365 form’s field and its Marathi language equivalent text will populate automatically in another field using the client side scripting.
Creating a RESX web resource in Dynamics 365
Follow the below steps to configure & create the RESX web resource in Dynamics 365.
Step 1 – Open the Power Apps solution explorer & navigate to the customizations as shown below.
Step 2 – Create a new RESX web resource with the below given properties.
- Resource Name – Make sure to add language code (English : 1033) and “.resx” extension in the resource name. In our case we will use English (United States) language in the RESX resource. Therefore, our resource name would be “CRMCrateRESX_1033.resx”.
- Type – Select “String (RESX)” as web resource type.
- Language – Select an appropriate language of your choice (Ensure to update the language ID in the web resource name).
- Upload File – Upload the previously created .Net RESX file in the web resource.
Step 3 – Save & publish this newly created RESX web resource.
Validate the changes in Dynamics 365
Thus, we learned the String (RESX) web resources in Dynamics 365.