Use BuiltIn parameters in Jasper Reports

Use BuiltIn parameters in Jasper Reports

Jasper provides few builtIn parameters which can be used in JRXML.
Click on this link for more information
Following are few builtin parameters

  1. LoggedInUserFullName :
    • Type of this parameter is ‘String’.
    • This parameter gives you full name of loggedin user.
  2. LoggedInUsername :
    • Type of this parameter is ‘String’.
    • This parameter gives you user name of loggedin user.
    • Example: If you want to show username and fullname of person at the bottum of your page then you can use this on your page footer
    "Last printed by " + $P{LoggedInUserFullName} + " on "  + new java.util.Date() 
    
  3. LoggedInUserTenantId :
    • Type of this parameter is ‘String’. Not applicable for Community Edition.
    • This is used to get organization of logged in user.
  4. LoggedInUserRoles :
    • Type of this parameter is ‘Collection<String>’.
    • This parameter gives you all roles of loggedin user.
    • Example : if you want to show only reports to user who has role ‘ROLE_ADMINISTRATOR’ then you can use this in print when expression
    ($P{LoggedInUserRoles}.toString().contains("ROLE_ADMINISTRATOR")) ? new Boolean(true) : new Boolean(false)
    
  5. LoggedInUserAttribute_<attribute name> :
    • Type of this parameter is ‘String’.
    • This built in parameter is used to get value of specific profile attribute by passing the name of profile attribute name.
    • Eample: lets say one of your profile attribute name is city and profile attribute value is Maxico.
      If you want to get value of city (value Maxico) in your JRXML then do this
      -> replace “_<attribute name>” to profile attribute name
      ie. LoggedInUserAttribute_city

As we know, we can add comma separated value to profile attribute but we can not directly use this profile attribute in JRXML as list. In order to use comma separated profile attribute as a list in your JRXML then refer this

Convert Comma Separated Profile Attribute to list in Jasper Reports