Skip to main content
How does EXPORT to server affect current process instances?

Meaning... I have 100+ active process instances.

I discover a bug in the final activity of the process.

I fix the bug and export the code to the server.

Do the 100+ active process instances fail at the last activity (because of the bug) or are they saved?

Thanks,
Randy
No, they're probably doomed - unless you can get to the code in K2.net Service Manager. Only new process instances will run on the newly exported version of the process.

Regards,
Ockert
If the error was repairable using Error/Repair Manager, the code change would have fixed all the active workitems?
Correct.

AND - if the error could have been repaired through the Error Repair functionality, the blue-print of the actual code in the database would have been changed and ALL other process instances - even if new ones were started in the same version - would have run on this new 'revised' code and therefore NOT experience the same problem.

Regards,
Ockert
Is there a way to get to the code? database? service mgr?

I know you can "repair" when it happens.

Any way of getting to it before it happens?

-Randy
Direct database access is not recommended nor allowed.

Regards,
Ockert
But you haven't said it's not possible!
Options:

1) Use the K2ROM and read the 100+ work list item
2) Use .clone() on the worklistitem and call .StartProcessInstance()
3) oWorkListItem.GotoActivity(K2ActivityName, false);

OR

1) Use the K2ROM and read the 100+ work list item

SourceCode.K2Mng.K2Manager oSvcMgr = new SourceCode.K2Mng.K2Manager();

oSvcMgr.Login(strK2Server, nK2Port);

foreach(SourceCode.K2ROM.WorklistItem oOriginalWLItm in oWorkList)
{

// get a reference to the original proc inst
SourceCode.K2ROM.ProcessInstance oOldProc = oOriginalWLItm.ProcessInstance;

// grab the current activity name for the original worklist item (it will be used later to GOTO the new proc inst)
string strOldActivityName =oOriginalWLItm.ActivityInstanceDestination.Name;

// create a new proc inst by leveraging the name of the old one
SourceCode.K2ROM.ProcessInstance oNewProc = oConn.CreateProcessInstance(oOldProc.FullName);

// create a new folio field
oNewProc.Folio = CreateNewFolio(oOriginalWLItm);
// copy over all the process data fields from the ORIGINAL -> NEW
foreach(SourceCode.K2ROM.DataField oFld in oOldProc.DataFields)
{
oNewProc.DataFields[oFld.Name].Value = oFld.Value;
}

// start the new proc inst
oConn.StartProcessInstance(oNewProc, true);
// now that we've started the process, we can retrieve the new proc inst id
// in case we need it later
int nNewProcInstID = oNewProc.ID;
// need to generate the serial number for the new worklist item. we first need to get the
// event inst id and platform (which is returned in a comma delimited string)
string strRes = this.GetEventInstID(nNewProcInstID, oConn.User.FQN );
string[] arParts = strRes.Split(',');
int nEventInstID = Convert.ToInt32(arParts[0]);
string strPlatform = arParts[1];
// create the serial number for the new worklist item
strSN = "," + nNewProcInstID.ToString() + "," + nEventInstID.ToString();
// open the NEW k2 worklist item
SourceCode.K2ROM.WorklistItem oNewWLItm = oConn.OpenWorklistItem(strSN, strPlatform);
// switch this to proper activity (utilizing the name from the original worklist activity)
oNewWLItm.GotoActivity(strOldActivityName);
// if selected, delete the proc inst from the DB (and possible the K2 Log db)
if(bDelOrigProcs)
{
// utilize K2Mgr (Service Manager) to delete the process instance
oSvcMgr.DeleteProcessInstances(oOriginalWLItm.ProcessInstanceID, bDelFromLog);
}
One more thing.

K2 guys: It would be nice to have a worklistitem upgrade funtion in future release!!!
Did you get this to work? Do you have the exe build for the community to use?

1) Use the K2ROM and read the 100+ work list item
2) Use .clone() on the worklistitem and call .StartProcessInstance()
3) oWorkListItem.GotoActivity(K2ActivityName, false);
Peter,

Yes, I do have an exe, but it is written for my K2 process.

The logic is pretty much straight forward.

Use the K2ROM and read the 100+ work list item

foreach(SourceCode.K2ROM.WorklistItem oWorkListItem in oWorkList)
{
SourceCode.K2ROM.WorklistItem oWorkListItemClone = oWorkListItemClone .Clone()

oWorkListItemClone .StartProcessInstance()

oWorkListItemClone.GotoActivity(K2ActivityName, false);
}
icon-quote.giflchoing:
Peter,

Yes, I do have an exe, but it is written for my K2 process.

The logic is pretty much straight forward.

Use the K2ROM and read the 100+ work list item

foreach(SourceCode.K2ROM.WorklistItem oWorkListItem in oWorkList)
{
SourceCode.K2ROM.WorklistItem oWorkListItemClone = oWorkListItemClone .Clone()

oWorkListItemClone .StartProcessInstance()

oWorkListItemClone.GotoActivity(K2ActivityName, false);
}


foreach(SourceCode.K2ROM.WorklistItem oWorkListItem in oWorkList)
{
SourceCode.K2ROM.WorklistItem oWorkListItemClone = oWorkListItem.Clone()

oWorkListItemClone .StartProcessInstance()

oWorkListItemClone.GotoActivity(K2ActivityName, false);
}

What happens if your very first activity isn't a client or server task, i.e. it's a piece of code that runs on the K2 server. Wouldn't you end up with something getting run again when it shouldn't? It would be great to see something that allowed you to select the activity to start at, before actually starting the process instance.

Reply