How to pass input parameter to beforeRender



  • Hi

    I playing around with jsreports and so far I like it very much. Unfortunately I am absolutely new to node.js.

    I use the setup, where jsreport makes the REST call to get the data directly from the server (beforeRender). Now I have to pass a parameter from the API Call to jsreport to the beforeRender action.

    To simulate this, I have made a new dataset named "params" in jsreport studio:
    {"input" : "Test"}

    How can I use this data in the beforeRender function?
    I tried this: request.data.$resources.params.input
    0_1507551466655_param.png

    Thx for a little jumpstart ...

    Reto E.



  • You should select your data set in the sample data template menu.

    0_1507559980298_upload-ddb456eb-3a32-4dfd-a821-70ebcf5f75d0

    Then you can reach the data in the script using

    function beforeRender(req, res, done) {
      console.log(req.data.myProperty)
      done()
    }
    


  • I selected it in the resources template menu (instead of the sample data).
    Thanks again. Now I got the basics sorted out, I'm able to start playing around.



  • Great. Good luck. :)


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.