11-23-2023 12:26 PM - edited 11-23-2023 12:27 PM
Hi,
is there an BrApi command that returns the Application Currencies, ideally as a list of strings?
I would like to use the output, i.e. the list of currencies, in an Extender business rule, where I need to loop through them.
Thank you
Solved! Go to Solution.
11-24-2023 04:27 AM - edited 11-24-2023 04:28 AM
BRApi.Utilities.GetApplicationProperties(si).CurrencyFilter. Manipulate it with StringHelper.SplitString to get it as a List of String objects.
11-24-2023 02:14 AM
Hi Andrea
I couldn't see a BRApi function that would get you this list - hopefully someone else can, but failing that you can query the AppProperty table to get the list.
Below is a snippet of code (VB.NET) that will give you what you need:
Using dbConn As DbConnInfo = BRApi.Database.CreateApplicationDbConnInfo(si)
'Query the App Property table to get the currency list
Dim sCurrencyFilter As String = BRApi.Database.ExecuteSql(dbconn, "SELECT Top 1 TextValue FROM AppProperty WHERE Name = 'CurrencyFilter'", False).Rows(0)(0)
'Split currency string into array of currencies
Dim currencies As String() = sCurrencyFilter.Split(New String() {", "}, StringSplitOptions.None)
'Loop through each currency
For Each curr In currencies
'Get currency object using currency name
Dim objCurrency As Currency = BRApi.Finance.Cons.GetCurrency(si, curr)
'Do what you like with the currency...
BRApi.ErrorLog.LogMessage(si, curr)
Next
End Using
Regards,
Mark
11-24-2023 04:27 AM - edited 11-24-2023 04:28 AM
BRApi.Utilities.GetApplicationProperties(si).CurrencyFilter. Manipulate it with StringHelper.SplitString to get it as a List of String objects.
11-24-2023 04:48 AM
Thank you both for your help!
I would have expected to see it in the formula helper panel, but maybe BrApi.Utilities is not included in there
11-24-2023 04:53 AM
It's there, but the helper tree can only go 2 levels deep. So you will find Brapi.Utilities.GetApplicationProperties, and if you select that and look at the Objects tab, you'll find the AppProperties object - click on it and you'll get its methods and properties, including CurrencyFilter.
11-24-2023 05:05 AM
Jack, that is brilliant. I never knew that you could click on the objects...
I used to scroll through intellisense.
11-24-2023 07:06 AM
Yeah, that opens a world 😉 happy digging!
11-24-2023 11:50 AM
Hi Andrea
You can use this approach also (if only interested in C#Currencies.Children) e.g.
Dim sb As New Text.StringBuilder
' Get Currencies
Currency.GetItems().ForEach(Sub(lambda) sb.AppendLine(String.Format("Name -> {0}, Id -> {1}", lambda.Name, lambda.Id)))
' Log Result -> Throw Error
BRApi.ErrorLog.LogMessage(si, "Currency Output", sb.ToString)