Page 1 of 1

Creating a report with parameters

PostPosted:Tue Aug 20, 2019 5:33 pm
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

Re: Creating a report with parameters

PostPosted:Sat Aug 24, 2019 10:28 am
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.

Re: Creating a report with parameters

PostPosted:Wed Aug 28, 2019 5:19 pm
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

Re: Creating a report with parameters

PostPosted:Sat Aug 31, 2019 9:20 am
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 2173 times
Remember that probably in your side will not incoming a path, it will be the UUID of the node.