cancel
Showing results for 
Search instead for 
Did you mean: 

Nuxeo LTS2023 Automation Script and Retrieving Folder Properties

Sudarshan_Ghate
Confirmed Champ
Confirmed Champ

I have the following code Automation script code fragment.

 

var query = "SELECT * FROM Folder WHERE ecm:primaryType = 'Invoices';
var resultSet = Repository.ResultSetQuery(
      input, {
        query: query}
    );
 
Console.log("Processing Result Set");
    if (resultSet.length === 0) {
      Console.error("No matching Invoice Folder.");
    }
    else {
      var targetFolder = resultSet[0];
  
How do I enumerate the folder properties?  I am trying to find the Folder Path so that I can execute the Document.Move and move the incoming document into the folder.
Thank you,
SG
  
3 REPLIES 3

Josh-F-Hyland
Employee
Employee

SELECT * FROM Invoices will get the Invoices documents, assuming that really is the Document Type and not just the title.

targetFolder.path will give you the path. Not sure what you mean by "enumerate the folder properties". Documents in Nuxeo aren't simple enums, they can be made of of many schemas. But you don't need that to get the path.

--
Hyland Sales Solution Engineer

Sudarshan_Ghate
Confirmed Champ
Confirmed Champ

@Josh-F-Hyland - Thank you.  I modified the query to pull from Invoices.  When I run the query in NXQL, it brings be back the correct result set.   However, path does not seem to return anything.  Here is the code that I have:

Console.log("Processing Result Set");
    if (resultSet.length === 0) {
      Console.error("No matching Invoice found.");
      return document;
    }
    else {
      Console.log("Matching Folder Found " + resultSet[0]);
      var targetFolder = resultSet[0];
      var newpath = targetFolder.path;
      Console.log("Document will be moved to " + newpath);
And it produces the following output.     I am not sure why newpath is undefined !
  
2025-03-05T11:11:44,621 WARN  [http-nio-0.0.0.0-8080-exec-7] [org.nuxeo.automation.scripting.helper.Console] [LOG] Processing Result Set
2025-03-05T11:11:44,658 WARN  [http-nio-0.0.0.0-8080-exec-7] [org.nuxeo.automation.scripting.helper.Console] [LOG] Matching Folder Found {ecm:uuid=c814bd3b-2a21-4fd9-9d28-4a14b5556f2e}
2025-03-05T11:11:44,661 WARN  [http-nio-0.0.0.0-8080-exec-7] [org.nuxeo.automation.scripting.helper.Console] [LOG] Document will be moved to undefined
 
I appreciate your assistance.
 

I apologize, I meant to clarify this in the first reply. The Repository.ResultSetQuery operation returns arrays of values, not "documents". So each array entry is just a simple value. IMO you probably want to use Repository.Query operation, which will return an array of complete documents (so you can use result[i].path, result[i].title, result[i]["myschema:myfield"], etc.) If you wanted to use Repository.ResultSetQuery you need to list the properties that you want to fetch e.g. "SELECT ecm:path FROM Invoices" *or* fetch each document using the Repository.GetDocument operation.

--
Hyland Sales Solution Engineer
Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.