Editar

Compartilhar via


getResourceString (Client API reference)

Returns the localized string for a given key associated with the specified web resource.

Syntax

Xrm.Utility.getResourceString(webResourceName,key)

Parameters

Name Type Required Description
webResourceName String Yes The name of the web resource.
key String Yes The key for the localized string.

Return value

A localized string.

Remarks

When you create RESX web resources you must explicitly set the language value and include the locale identifier (LCID) for the appropriate language in the name of the web resource. For example, new_/strings/MyAppResources.1033.resx would contain resources for English language. See Microsoft locale ID values for a list of LCID values.

For example Xrm.Utility.getResourceString("new_/strings/MyAppResources","hello") will return the localized string value for the resource key hello within the new_/strings/MyAppResources.1033.resx web resource if the user's preferred language is English. Notice that the function doesn't refer to any specific language or full name of any RESX web resource. This functionality depends on the RESX web resource being associated to the calling JavaScript web resource as a dependency. More information: Web resource dependencies.

The appropriate string value will be determined by the individual user's language preference and the languages available in the organization. If a localized string is not found that matches the user's language preference, the localized string will automatically fallback to the base language for the organization. If no matching localized string is found for the organizations base language, a null value will be returned. If no matching RESX web resource is found for user's LCID, an exception {webResourceName} does not exist. will be thrown.

Xrm.Utility
String (RESX) web resources
Web resource dependencies