Accessing XFStrings through Business Rules

MarcusH
Contributor II

Does anyone know if it's possible to access XFStrings through Business Rules? We are adding other languages to our application and we are using XFStrings for Cube Views and Dashboards. We want to present our custom BR error messages in the user's chosen language so we thought XFStrings would be a good place to keep them. However we don't know if it's possible and if it is possible, how to do it. We are currently using Transformation Rules for some other areas but we want to have a single place where the translations can be managed.

 

Thanks

1 ACCEPTED SOLUTION

MarcusH
Contributor II

Hi hiren

I needed to change your code a little bit but I have got it working. And you only need one Dashboard parameter. I changed the parameter default value from

XFString(Dummy, Culture=|!Culture!|)

to 

XFString(|!XFstr!|, Culture=|!Culture!|)

MarcusH_0-1683905422343.png

Then I changed the Rules to this :

Dim params As New Dictionary(Of String, String) From {{"Culture", "fr-FR"}, {"XFStr", "str_Currency"}}

Dim ParamDisplayInfo As DashboardParamDisplayInfo = BRApi.Dashboards.Parameters.GetParameterDisplayInfo(si, False, params, "Param_Dummy")
brapi.ErrorLog.LogMessage(si, ParamDisplayInfo.DefaultValueAfterSubstitution)

 Note that there are only 4 params - GUID.empty is removed - and the parameter name does not take the dashboard name. This might be a difference in versions.

So the Rules pass through the XFString name as well as the Culture code. Works beautifully. Thank you so much for your help.

View solution in original post

4 REPLIES 4

OS_Pizza
Contributor III

@MarcusH 

Why dont you go for Dashboard XFBRString instead of XFString. Below example is to show how you can send some information to XFBR and get value in return by applying any logic.

BRString(brRuleName, GetUserCulture, optionalName1 = var1, optionalName2 = var2)

if (args.FunctionName.XFEqualsIgnoreCase("GetUserCulture"))
 Dim UI As UserInfo = BRApi.Security.Authorization.GetUser(si, si.UserName)
 Dim U_Culture As String = UI.UserPreferences.Culture
 Return U_Culture 
End If 

 Can you explain about your requirement through some screenshot as it is not very clear.

There are checks on the Load and Transform step because Trial Balance and IC data is loaded separately and we want to tell the user in their language what the problem is ie you are loading IC data into the TB workflow. So if my culture is English I will see 'There is a problem...', if it's French I will see 'Il y a un problème...', if it's Greek I will see 'Υπάρχει πρόβλημα...' and so on. We are using XFStrings to hold the Cube View and Dashboard text and caption information in different languages. The Load and Transform error messages are generated by Business Rules and we do not want to put the error messages in the Rules themselves because the foreign language has to be validated. We do not want to give someone access to Rules just so they can check the error messages in their language. It makes sense to use XFStrings which are set up for localization and I want to know if it is possible to read XFString entries through Business Rules. 

Dashboard XFBR String is an element of Business Rules - can they look up XFString items? If so what is the syntax? I suspect the answer is no in which case we will use Transformation Rules to lookup the foreign language text. 

hiren
New Contributor III

Create a Dashboard Parameter for each string with XFString function in it as below (add Culture value as another Param which will be passed from BR),
Screenshot 2023-05-12 at 7.13.40 PM.png

Use the follow snippet in BR to access the string in specified Culture,

Dim params As New Dictionary(Of String, String) From {{"Culture", "fr-FR"}}
Dim ParamDisplayInfo As DashboardParamDisplayInfo = BRApi.Dashboards.Parameters.GetParameterDisplayInfo(si, False, params, GUID.Empty, "CustomSolutions.Param_Dummy")
brapi.ErrorLog.LogMessage(si,  ParamDisplayInfo.DefaultValueAfterSubstitution)

 

MarcusH
Contributor II

Hi hiren

I needed to change your code a little bit but I have got it working. And you only need one Dashboard parameter. I changed the parameter default value from

XFString(Dummy, Culture=|!Culture!|)

to 

XFString(|!XFstr!|, Culture=|!Culture!|)

MarcusH_0-1683905422343.png

Then I changed the Rules to this :

Dim params As New Dictionary(Of String, String) From {{"Culture", "fr-FR"}, {"XFStr", "str_Currency"}}

Dim ParamDisplayInfo As DashboardParamDisplayInfo = BRApi.Dashboards.Parameters.GetParameterDisplayInfo(si, False, params, "Param_Dummy")
brapi.ErrorLog.LogMessage(si, ParamDisplayInfo.DefaultValueAfterSubstitution)

 Note that there are only 4 params - GUID.empty is removed - and the parameter name does not take the dashboard name. This might be a difference in versions.

So the Rules pass through the XFString name as well as the Culture code. Works beautifully. Thank you so much for your help.