Report template metadata



  • Hi!
    I need to store some additional info (Map<String, String> or dictionary) with each template and be able to query this info with along with the list of templates. Is it possible?



  • Hi,

    you can extend template type with custom string property inside a custom extension.
    Here are the docs for writing custom extension
    https://jsreport.net/learn/custom-extension

    or simply add just this to your server.js.

    const jsreport = require('jsreport')
    jsreport.use((reporter) => {
      reporter.documentStore.model.entityTypes['TemplateType'].foo = { type: 'Edm.String' }
    })
    jsreport.init()...
    


  • I want actually to have something like template.metadata = {
    customerId: "",
    label: ""
    };
    I need this to solve following usecase - We have set of default reports and many customers, some of them want reports to look differently. Having metadata, I will be able to store for example customerId, base report type it corresponds to, etc...



  • Yes, so why don't you add two, three... new props to the template?

    Or you can have one extra prop that serializes what ever you want. Like a map.



  • Sure, I can... I just thought that it can be a good base functionality :)



  • Yes perhaps. Thanks. Lets see if it gets requested more often.


Log in to reply
 

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