I used the link how to start workflow for bundle using core service? and wrote the below code.
private bool StartWorkflow(VirtualFolderData bundledata, out string processInstanceID)
{
bool isStarted = false;
processInstanceID = string.Empty;
try
{
string processdefID = GetContextualProcessDefinitionIDByName(objClient, "Publish Bundle Workflow", bundledata.LocationInfo.ContextRepository.Title);
StartWorkflowInstructionData workflowInstruction = new StartWorkflowInstructionData() { ProcessInstanceTitle = "Publishing the Bundle " + bundledata.Title};
workflowInstruction.Subjects = new[] { new LinkToIdentifiableObjectData() { IdRef = bundledata.Id } };
workflowInstruction.ProcessDefinition = new LinkToProcessDefinitionData() { IdRef = processdefID };
ProcessInstanceData pid = (ProcessInstanceData)objClient.StartWorkflow(bundledata.LocationInfo.ContextRepository.IdRef, workflowInstruction, new ReadOptions());
processInstanceID = pid.Id;
Log(FormatDate() + "Publish Bundle Workflow process has been initiated!!!!!! Title - " + pid.Title);
if (!string.IsNullOrEmpty(pid.Id)) isStarted = true;
}
catch (Exception ex)
{
Log(FormatDate() + "Exception during Starting the workflow with message : " + ex.Message);
}
return isStarted;
}
and then based on the Process Instance ID I'm tring to force finish the workflow process.
string workFlowProcessID = string.Empty;
if (StartWorkflow(bundledata, out workFlowProcessID))
{
Log(FormatDate() + "Bundle has been sent to workflow!!! Process Instance ID - " + workFlowProcessID);
objClient.ForceFinishProcess(workFlowProcessID, liveApprovalStatusID, objReadOptions);
Log(FormatDate() + "Force Finishing the workflow");
}
My process instance is created but there is no bunlde attached to it. And while doing the force finish I'm facing and oracle error.
Exception in Perform Testing() A database error occurred while executing Stored Procedure "TCM_WORKFLOW.ARCHIVE_PROCESS_INSTANCE ". ORA-02292: integrity constraint (TCMDBUSER.FK_WFL_ACT_INST_PROC_INST) violated - child record found ORA-06512: at "TCMDBUSER.TCM_WORKFLOW", line 1023 ORA-06512: at line 1
This isssue is intermittent and sometimes the code works absolutely fine. I can force finish the process manually from CME.
Please advice if I'm missing something.