Content Management and Capture

 View Only
  • 1.  Use filenet.api.dll to search for documents filed under a folder

    Posted Mon December 18, 2023 08:34 PM

    I have a few folders, each with a lot of documents. For illustration, these are the example documents and folders:

    Doc1 - CaseNum: 111; Folder: Folder1

    Doc2 - CaseNum: 222; Folder: Folder1

    Doc3 - CaseNum: 111; Folder: Folder2

     

    I would like to search for documents filed in a folder using filenet.api.dll. In the above example, I was able to search for CaseNum of 111 and find Doc1 in Folder1 and Doc3 in Folder2. What I want is to search Folder1 for documents whose CaseNum value is 111.  I tried to use SearchScope and SearchSQL. I was able to specify just the CaseNum in the where clause, but could not find a way to specify a folder. I don't want to search for CaseNum and manually filter for Folder1, because that will throw away a lot of search results. Any suggestions how to search for both CaseNum and folder?

     

    Thanks,

    Walter



  • 2.  RE: Use filenet.api.dll to search for documents filed under a folder

    Posted Tue December 19, 2023 04:30 AM

    Check out the documentation for the INFOLDER query operator.



    ------------------------------
    Mike
    ------------------------------



  • 3.  RE: Use filenet.api.dll to search for documents filed under a folder

    Posted Tue December 19, 2023 01:20 PM

    Thanks Mike for the pointer of the INFOLDER operator. I found the relevant section in Working with Queries - IBM Documentation, and able to accomplish what I wanted to do.






  • 4.  RE: Use filenet.api.dll to search for documents filed under a folder

    Posted Tue December 19, 2023 11:02 AM

    Try this

    using Filenet.Api.Core;
    using Filenet.Api.Util;

    // Assuming you have a reference to your ObjectStore
    ObjectStore objectStore = ...;

    // Specify the search criteria
    string caseNumValue = "111";
    string folderName = "Folder1";

    // Construct the search query
    string searchQuery = "SELECT * FROM Document WHERE CaseNum = '" + caseNumValue + "' AND This INFOLDER '" + folderName + "'";

    // Create a SearchSQL object
    SearchSQL searchSQL = new SearchSQL();
    searchSQL.SetQueryString(searchQuery);

    // Create a SearchScope to specify the search scope (e.g., the root folder)
    SearchScope searchScope = new SearchScope(objectStore);

    // Execute the search
    RepositoryRowSet rowSet = searchScope.FetchRows(searchSQL, null, null, false);

    // Process the search results
    foreach (RepositoryRow row in rowSet)
    {
        // Access the document properties or perform other actions
        Document document = (Document)row.GetObject();
        // Process the document as needed
    }

    Source: https://data-encoder.com/



    ------------------------------
    Zimba toki
    ------------------------------



  • 5.  RE: Use filenet.api.dll to search for documents filed under a folder

    Posted Wed December 20, 2023 03:07 PM

    Thanks Zimba for the details.

    Yes I was able to accomplish what I wanted. BTW, SearchScope.FetchRows() is returning IRepositoryRowSet. I was able to get the document object by first getting its Id property from IRepositoryRow.