Page 1 of 1

Read File names under a folder using .rep format openkm

PostPosted:Wed May 25, 2022 7:27 am
by nishant8900
Hi all,

I need to read all files under a separate folder. I have given the path , when i am trying to read it won't work.
Code: Select all
import com.openkm.api.OKMFolder;
import com.openkm.bean.ContentInfo;

ContentInfo ci = OKMFolder.getInstance().getContentInfo(null, "/okm:root/testfolder");
 String doc=  ci.getDocuments();
print("$$",doc) 
returns null values. Please provide some suggestion guys.

Thanks

Re: Read File names under a folder using .rep format openkm

PostPosted:Sun May 29, 2022 4:43 pm
by jllort
The getContentInfo method returns how many documents you have into a hierarchy, do not list the name of the documents. If you need to list the name of the documents should use getChildren method -> https://docs.openkm.com/kcenter/view/ok ... etChildren

Re: Read File names under a folder using .rep format openkm

PostPosted:Tue May 31, 2022 10:53 am
by nishant8900
Hi ,

Even though i tried with that OKMDocument.getInstance().getChildren is not working. Here i am tying as
Code: Select all
for (Document doc : OKMDocument.getInstance().getChildren(null, "/okm:root/testrecord/")) {;
  System.out.println(doc);
  actMap.put("filename",doc);
}
Showing error as
Code: Select all
Class: net.sf.jasperreports.engine.fill.JRExpressionEvalException
Message: Error evaluating expression for source text: $F{filename}
Guide me I don't know how to proceed further.

Thanks

Re: Read File names under a folder using .rep format openkm

PostPosted:Wed Jun 08, 2022 3:56 am
by nishant8900
Hi ,

I achieved the output for reading files under folder in scripting. I need this for report(.rep) format file. Here is the scripting code,
Code: Select all
import com.openkm.bean.*;
import com.openkm.util.*;
import com.openkm.api.*;

ContentInfo ci = OKMFolder.getInstance().getContentInfo(null,"/okm:root/test");
print(ci.getFolders()+"<br>");
print(ci.getDocuments()+"<br>");
print(ci+"<br>");

for (Document doc : OKMDocument.getInstance().getChildren(null, "/okm:root/test/test_sample_record/")) {
    print(doc.path+"<br>");
}
I need this for my report too. Pls guide for me further.

Thanks

Re: Read File names under a folder using .rep format openkm

PostPosted:Sun Jun 19, 2022 4:59 pm
by jllort
Debug this class https://github.com/openkm/document-mana ... rvlet.java about how parameters are sent in from the UI to the server.

I suggest take UsersLogin report as a template and debug how data is moved from UI into a map or parameters and then used in the scripting https://docs.openkm.com/kcenter/view/ok ... -pack.html