I've created a workflow that kicks off multiple IPC events. The number of IPC events depends on the number of items in a database table. A subworkflow must be created for each row, which represents an account. The subworkflow must then be routed to the manager of that account.
The trouble is that the only way I've found so far to kick off multiple sub-workflows is to add multiple destination users. Some of these accounts will be managed by the same person, but K2 is only kicking off one sub-workflow per user even if some users are added multiple times.
I've tried this as a destination rule:
public void Main(ref DestinationRuleContext K2) {
K2.ResolveQueuesToUsers = true;
SourceCode.K2Utilities.DSHelper oDSH = new SourceCode.K2Utilities.DSHelper(SourceCode.K2Utilities.DSHelper.DSHelperNewOptionsEnum.DefaultLDAPDomain);
System.DirectoryServices.DirectoryEntry oDEManager;
string sManager;
bool bAllTrue = true;
CDest1 oDest1 = new CDest1();
oDest1.Main(ref K2);
if (oDest1.IsSuccess == true) {
//== sendto
int accounts= HelperDLL.GetNoOfAccounts();
for(int i=0; i < accounts; i++) {
K2.Destinations.Add(DestinationType.User, "User" + i);
}
if (bAllTrue == false) return;
}
}
Which will just add User1, User2 etc, thus kicking off the number of workflows that I need. However each one of these uses up a licence and there could easily be more accounts than we have licences, therefore this isn't really an option.
The idea of using a loop occurred to me, but the next stage in the workflow (the main workflow that kicks off the subworkflows) requires that all subworkflows be completed first.
Any ideas?