OL Learn

Unused subprocess list

Hi,

We have a lot subprocesses that are created long time ago and we have no idea are they still used in some process/subprocess or we can delete them. Is there any way to get list of unused subprocesses?

Thanks.

There’s no native way to get that list, but you can write a script that will do it for you.
Here’s a sample script:

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
xmlDoc.loadXML(Watch.ExpandString("%c"));

var subs = xmlDoc.selectNodes("//SubProcessList/Process/Name");
 
for(var i=0;i<subs.length;i++){
  var subName = subs[i].text;
  var used = xmlDoc.selectSingleNode('//SubProcessList/Process/Node/Config[contains(.,"'+subName+'")]');
  Watch.Log( subs[i].text + " is" + (used ? " " : " NOT ") + "used",used ? 3 : 2);
}

Create a new process in Workflow and set its job file to be your Workflow Configuration file. Insert a Run Script task and paste that code into it, then run the process in Debug mode.

The code retrieves a list of subprocesses from the configuration file, then loops through the list. For each subprocess in the list, it logs whether or not the subprocess is being called by at least one other process (or subprocess).

Phil,
Assuming the same sort of script works, what would the XPath be to check a process instead of a sub?

Not quite sure what you’re asking: processes are either active or inactive, that is displayed plainly in the Workflow Configuration tool. Whether or not a process is actually being used is a different story: you’d have to check the logs to see if it’s been called at some point… And even then, it wouldn’t be the definitive answer because some processes might be scheduled to run only once a month or twice a year.

Now if what you really want to know is whether a process is specifically called in a Send To Process task, then you can use a script that’s almost identical to the previous one:

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
xmlDoc.loadXML(Watch.ExpandString("%c"));
var procs = xmlDoc.selectNodes("//ProcessList/Process/Name");
for(var i=0;i<procs.length;i++){    
  var procName = procs[i].text;
  var used = xmlDoc.selectSingleNode('//Process/Node/Config[contains(.,"'+procName+'")]');
  Watch.Log( procs[i].text + " is" + (used ? " " : " NOT ") + "used",used ? 3 : 2);
}

Thanks, this answers my question. I was wondering if Workflow could tell the end user if their processes are being used or not because I frequently get asked this question. I’ve been directing them to use the logs, so its good to know I’m providing the right info and that Workflow really cant tell them definitively if a process is actually being used regularly or not. Such statistics could be saved into the Workflow repository though right?

Yep, that would be one way of doing it.