Menu

How to use Field Expression in fileName options?

ART Help
2023-08-30
2023-09-18
  • Sirichoke Kunnavatsuwan

    Dear all,

    I try to but no success with Date parameter. Eg.
    fileName: "Listing as of f[#execDate#|dd-MM-yyyy]f"

    The result will shown as "Listing as of f_2023-08-30-00-00-00|dd-MM-yyyy_f"

    Thanks
    Sirichoke K.

     
  • Makka Pakka

    Makka Pakka - 2023-09-04

    There are instructions in the manual, you can refer to:

    Dates
    You can substitute the current date by using the expression f[date]f. This will output the current date in yyyy-MM-dd format e.g. 2017-11-10. You can use the expression f[datetime]f to substitute the current date and time in yyyy-MM-dd HH:mm:ss.SSS format e.g. 2017-11-10 11:25:21.045. Both date and datetime field expressions can also specify a different date other that "now" and additionaly specify the output format, output format locale, input format and input format locale. These additional items are specified separated by | i.e f[date field name|date specification|output format|output format locale|input format|input format locale]f.

     
  • Sirichoke Kunnavatsuwan

    I succeed with data, datetime, but have no luck with report paramerter.
    My point is trying to customize date parameter into my desired format.

    Can u suggest me the sample of this?

     
    • Kan

      Kan - 2023-09-18

      Field expressions work with predefined "fileds" - user name, current date etc.
      You can use groovy expression instead.
      If "execDate" parameter is of type Date then expression should be like:
      {"fileName" : "Listing as of g[execDate.value.format('dd-MM-yyyy')]g"}

       

      Last edit: Kan 2023-09-18
      • Sirichoke Kunnavatsuwan

        Thanks but still out of luck....
        I followed your advice but error occurred....

        java.lang.SecurityException: Unexpected type: class art.reportparameter.ReportParameter, value = ReportParameter{reportParameterId=477}
            at art.utils.GroovySandbox.filter(GroovySandbox.java:155)
            at org.kohsuke.groovy.sandbox.GroovyValueFilter.filterReturnValue(GroovyValueFilter.java:26)
            at org.kohsuke.groovy.sandbox.GroovyValueFilter.onGetProperty(GroovyValueFilter.java:73)
            at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:288)
            at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:292)
            at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:318)
            at Script1.run(Script1.groovy:1)
            at groovy.lang.GroovyShell.evaluate(GroovyShell.java:441)
            at groovy.lang.GroovyShell.evaluate(GroovyShell.java:476)
            at groovy.lang.GroovyShell.evaluate(GroovyShell.java:450)
            at art.utils.ExpressionHelper.processGroovy(ExpressionHelper.java:702)
            at art.utils.ExpressionHelper.processString(ExpressionHelper.java:147)
            at art.utils.ExpressionHelper.processString(ExpressionHelper.java:109)
            at art.utils.FilenameHelper.getBaseFilename(FilenameHelper.java:163)
            at art.utils.FilenameHelper.getBaseFilename(FilenameHelper.java:66)
            at art.utils.FilenameHelper.getFilename(FilenameHelper.java:237)
            at art.utils.FilenameHelper.getFullFilename(FilenameHelper.java:259)
            at art.runreport.RunReportController.runReport(RunReportController.java:640)
        
         
        • Kan

          Kan - 2023-09-18

          You can add the class name (art.reportparameter.ReportParameter) to groovy-whitelist.txt or set "enableGroovySandbox" to false in art-custom-settings.json and restart.

           

Log in to post a comment.