06-25-2019 07:15 PM
Is there a way to delete orphan folders with the Unity API or is that only accomplished in the thick client with scheudling tasks
06-26-2019 09:19 AM
Hi Brendan,
In Workflow, before you perform the action to auto-folder a document to another folder, you can run an action to get the folder that the active document is in, and put that folder information into a PropertyBag. Then after the document is moved to another folder, run another action to delete the folder that is specified in the PropertyBag. This will delete orphaned folders that has been orphaned by this Workflow action.
06-26-2019 04:25 AM
Hi, Brendan,
We do something similar to this to find folders with keyword values that shouldn't exist and delete the keywords:
We come up with the SQL to identify what we're looking for, e.g. in this case, something like:
SELECT foldernum FROM hsi.folder f WHERE NOT EXISTS (
SELECT 1 FROM hsi.folder p WHERE f.parentfoldernum = p.foldernum
);
Possibly adding in parameters like a date range, set of which folder types should be included, etc.
06-26-2019 07:18 AM
To tie together Sean's answer and the exact question Brendan asked-
It is *not* possible to use the API to just call one method and tell it "delete the orphaned folders".
It is possible to do the same work yourself using the API combined with SQL queries (just as Sean described).
It *might* be possible to do the same thing using pure API (no SQL of your own database), but the code would be muuuuuuuch more complex, much slower (maybe slow enough as to be effectively impossible in a reasonable sized environment), and there might be information you would need that just isn't available through the API.
06-26-2019 07:45 AM
Greetings Alex,
I know that the API can delete folder by ID with a short script
===========================================================
public void DeleteFolder(Hyland.Unity.Application G_Application)
{
if (G_Application != null)
{
try
{
lstoutput.Items.Clear();
Core C = G_Application.Core;
FolderManagement folderManager = C.FolderManagement;
Folder folder = folderManager.GetFolderByID(1659);
folderManager.DeleteFolder(folder);
lstoutput.Items.Add("Folder Successfully Deleted");
}// end try
catch (UnityAPIException UnityEX)
{
lstoutput.Items.Add(UnityEX.Message);
G_Application.Diagnostics.Write(UnityEX.Message);
}// end catch
catch (Exception Ex)
{
lstoutput.Items.Add(Ex.Message);
G_Application.Diagnostics.Write(Ex.Message);
}// end catch
}//end if
else
{
lstoutput.Items.Clear();
lstoutput.Items.Add("You are Not Connected to OnBase");
}
}
======================================================
The folder auto-name string is the keyword (email address)
When an action in workflow is performed the document will be auto-foldered into a new filing cabinet
My goal is to delete the orphan folder it was originally in without have to wait 24 hours for a scheduled process to do so . So my other question would be how can I identify that particular orphan folder with SQL to delete it ?
06-26-2019 09:19 AM
Hi Brendan,
In Workflow, before you perform the action to auto-folder a document to another folder, you can run an action to get the folder that the active document is in, and put that folder information into a PropertyBag. Then after the document is moved to another folder, run another action to delete the folder that is specified in the PropertyBag. This will delete orphaned folders that has been orphaned by this Workflow action.
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.