Jump to content
We've recently updated our Privacy Statement, available here ×
  • How To Maintain Dynamic Currency Symbol For Different Organizations


    akovach
    • Features: Localization, Parameters, Reports Version: v7.1, v6.4.2 Product: Jaspersoft® Studio

    Issue Description

    User wants to have different currency symbol for each Organization. User can format text fields in .jrxml report with different patterns. However, these patterns does not allow to use different currency symbols


    Resolution

    There is a way to maintain different currency symbol using Org attributes to create a pattern for currency text field.

    First step would be creating two Org attributes 'language' and 'region'. Go to Manage > Organizations, choose your organization > edit, add two attributes with values 'sv' and 'SE' accordingly (These values represent Sweden Locale).

    attributes.png.76ad81684540412a0f308604a60f54e0.png

    A report, i created for test has one text field and static text field:

    report.png.1961bf6bad5e2320e0898c060e7f3686.png

    Second step is a creation of parameters for pattern. For our pattern we would need three paramters (Type String):

    • LoggedInTenantAttribute_language
    • LoggedInTenantAttribute_region
    • CurrencyPattern

    Parameters 'LoggedInTenantAttribute_language' and 'LoggedInTenantAttribute_region' are built-in attributes parameters in TIBCO JasperReports® Server so we do not need expression for them. For parameter CurrencyPattern insert the following expression:

    ((DecimalFormat)(NumberFormat.getCurrencyInstance(new Locale($P{LoggedInTenantAttribute_language}, $P{LoggedInTenantAttribute_region})))).toPattern().replace("u00a4", DecimalFormatSymbols.getInstance(new Locale($P{LoggedInTenantAttribute_language}, $P{LoggedInTenantAttribute_region})).getCurrencySymbol())
    

    Then add a pattern for your text field. Go to text field properties > Text Field tab > Pattern Expression and choose parameter CurrencyPattern.

    Lets test this report. Publish report from TIBCO Jaspersoft® Studio to JasperReports Server, login with user which belongs to your organization and run the report. As a result you get a text field with formatted currency sign (Sweden kr in our case)

    result.png.f5b87089f1434f7e65fb95e74c27ea91.png


    References


    akovach case ref. 01583717

    currencytest.jrxml


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...