• Creating a report with parameters

  • We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #48679  by DrydenK
 
Hi,
I'm trying to create a report to output the number of folders and files within some folder that exists in our OpenKM. I would like to allow the folder to be selected when the report is generated, but I can't get OpenKM to ask the name of the folder.

I've created the following params.xml file:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE report-parameters PUBLIC "-//OpenKM//DTD Report Parameters 2.0//EN"
                                   "http://www.openkm.com/dtd/report-parameters-2.0.dtd">
<report-parameters>
  <input label="path" name="path" type="folder"/>
  <input label="From" name="from_date" type="date">
    <validator type="req"/>
  </input>
</report-parameters>
OpenKM ask for the date, but the value field for folder does not appear and remains blank. I would like to use value of 'path' to feed the following query in the report:
Code: Select all
import com.openkm.dao.*;
import com.openkm.dao.bean.*;
import com.openkm.bean.*;
import com.openkm.util.*;
import com.openkm.api.*;

List al = new ArrayList();
ContentInfo ci = OKMFolder.getInstance().getContentInfo(null, "/okm:root/"+path);
Map usr = new HashMap();
usr.put("Folders", ci.getFolders());
usr.put("Documents", ci.getDocuments());
usr.put("Size", FormatUtil.formatSize(ci.getSize()));
al.add(usr);

return al;
When I run the report, it returns blank. If I use some hardcoded path in the query instead of the variable, the report works fine, so I know that the rest of the code is sound.

Could somebody point what I'm missing?

Tks,

Roberto
 #48698  by jllort
 
You are not using the parameters into the scripting. I suggest take a look at https://docs.openkm.com/kcenter/view/ok ... ering.html

Also, you can download the UserLogin.rep https://docs.openkm.com/kcenter/view/ok ... -pack.html rename as zip file and take a look how has been built.
 #48735  by DrydenK
 
jllort wrote: Sat Aug 24, 2019 10:28 am You are not using the parameters into the scripting. I suggest take a look at https://docs.openkm.com/kcenter/view/ok ... ering.html
Sorry, I don't understand. Do I have to make some specific declaration that I'm using that name? I'm using it at the end of line 8 of the script:
ContentInfo ci = OKMFolder.getInstance().getContentInfo(null, "/okm:root/"+path);
^^^^^

Also, all the examples in the report pack page use 'Date'. I had seen that page and looked at it, but as I mentioned, date works, anything else doesn't.

Thank you,

Roberto
 #48755  by jllort
 
First, you are adding parameters in the report what are not using in the script, it does not have any king of sense, anyway this is not the issue, your problem is that is not allowing you to choose a folder in your system, no?

I have checked an input of type folder and it allows to choose a folder.
Selección_006.png
Selección_006.png (41.33 KiB) Viewed 1757 times
Remember that probably in your side will not incoming a path, it will be the UUID of the node.

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.