'**********************************************************
' InitializeCancelTrainingsForDocuments	'added by CC-000446
' @description: initializes the cancel training workflow (if started on document objects)
' @param: 
' @return: 
'**********************************************************
Function InitializeCancelTrainingsForDocuments
	wfvariables.recTrainees.MultiSelect = True

	wfvariables.sDocumentNumber.Value = "-"	'currently in the beforeforward event is checked it the workflow got a document. in this case we don't need a document, so we set the variable to -
	wfvariables.recStructure.iFolderID.Value = "1"	'this value is set for compatibility to the BPL Framework, cause currently no client protocol will be stored if the value is not set. And if no client protocol is set the merge instances function will not work

	For aW =0 To thisprocess.WFFile.FileObjects.Count-1		
		
		'check, if there is a distribute process running
		sProcessIDs = getProcessIDByObject(thisprocess.WFFile.FileObjects.Item(aW).Id, "CD - Distribute")
		debug2File sProcessIDs
		aProcessIDs = Split(sProcessIDs,";")
		
		For Each sProcess In aProcessIDs
			debug2File "Prozess: " & sProcess
			If sProcess <> "" Then
				sRActivityID = getRActivityId(sProcess)
				sDataFields = getActivityVariables(sRActivityID)
				Dim oXmlData : Set oXmlData = CreateObject("Msxml2.DOMDocument")
				If oXmlData.loadXML(sDataFields) = True Then
					'select variable sPersonRegisterID
					Set oPersonRegisterID = oXmlData.selectSingleNode("//DataFields/DataField[@Name='sPersonRegisterID']")
					
					Dim oXMLVariable : Set oXMLVariable = CreateObject("Msxml2.DOMDocument")
					If oXMLVariable.loadXML(oPersonRegisterID.text) = True Then
						sPersonObjectID = oXMLVariable.selectSingleNode("/WFVar/String").text
						debug2File "Person ObjectID: " & sPersonObjectID
						
						'CC-000900
						'sReturn = getPersonObjectInformation(sPersonObjectID)
						Set myPerson = getPersonObjectInformation(sPersonObjectID)

						'CC-0009000
						Set o1 = wfvariables.recTrainees.CreateListItem
						o1.Item("sName").Value = myPerson.sPersonName
						o1.Item("sLogin").Value = myPerson.sPersonLogin
						o1.Item("sTrainingStatus").Value = myPerson.sPersonTrainingStatus
						o1.Item("sStatusInformation").Value = myPerson.sPersonStatusInformation
						'o1.Item("sTrainingDate").Value = aReturn(4)
						o1.Item("sTrainingType").Value = myPerson.sPersonTrainingType		
						o1.Item("sEmail").Value = myPerson.sPersonEmail
						o1.Item("sResponsible").Value = myPerson.sPersonResponsible
						o1.Item("sUserID").Value = myPerson.sPersonUserID
						o1.Item("sDocTitle").Value = myPerson.sDocTitle
						o1.Item("sDocNumber").Value = myPerson.sDocNumber
						o1.Item("sDocVersion").Value = myPerson.sDocVersion
						o1.Item("sFolderID").Value = myPerson.sFolderID
						o1.Item("ID").Value = sPersonObjectID
						o1.Item("sProcessID").Value = sProcess
						o1.Item("sDelete").Value = "nein / no"							
						
						If o1.Item("sTrainingType").Value = "Leseschulung / Read and understood" Or o1.Item("sTrainingType").Value = "" Then
							wfvariables.recTrainees.AddListItem o1			
						End If	
					End If
				End If
			End If
		Next
	Next
End Function