'**********************************************************
' informAboutPreviousVersion (added for CC-000919)
' @description: gets data from a previous version and informs the user if the previous version already has an invalidation date
' @param: none
' @return: nothing
'**********************************************************
Function informAboutPreviousVersion
	sPreviousInvalidationDate = getFieldValueByInternalName(wfvariables.recStructure.iPreviousDocumentID.value, wfvariables.recStructure.iDocumentType.value, "m_doc_invalidationdate")
	if sPreviousInvalidationDate <> "" Then
		msgbox getMessageText("StandardWF", "PreviousDocumentInvalidationDate", "Bitte beachten Sie, dass die Vorgngerversion bereits ein Rcknahmedatum besitzt") & " (" & sPreviousInvalidationDate & ").",vbInformation,"enaio"
	End If
	
End Function

'**********************************************************
' getFieldValueByInternalName (added for CC-000919)
' @description: gets a field value of an object
' @param: lObjectID - the object id of the object
' @param: lObjectType - the object type id of the object
' @param: sInternalName - the internal name of the field for which the value should be get
' @return: the value of the field, if the field can not be found or an error occures an empty string will be returned
'**********************************************************
Function getFieldValueByInternalName (lObjectID, lObjectType, sInternalName)
	getFieldValueByInternalName = ""
	Dim oJob : Set oJob = drtsession.CreateJob("dms","GetObjectDetails")
	With oJob
		.AddInParam "Flags", 16,2
		.AddInParam "Encoding", "UTF-8",1
		.AddInParam "ObjectID", CLng(lObjectID), 2
		.AddInParam "ObjectType", CLng(lObjectType), 2
	End With
	iRet = oJob.Execute
	If iRet = 0 Then
		Dim sFileName : sFileName = Split (oJob.GetOutFiles,";")(0)

		Dim xmlDoc : Set xmlDoc=CreateObject("Msxml2.DOMDocument")
		loadsuccess = xmlDoc.load(sFileName)

		If loadsuccess = True Then	
			path = "//Field[@internal_name='" & sInternalName & "']"
			Set oField = xmlDoc.selectSingleNode(path)
			If Not oField Is Nothing Then
				getFieldValueByInternalName = oField.text
			End If
		Else
			'can not read the field, should not happen
			getFieldValueByInternalName = ""
		End If
		Set xmlDoc = Nothing
	Else
		'error in the querry, should not happen
		getFieldValueByInternalName = ""
	End If

	Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
	If objFSO.FileExists(sFileName) Then
		objFSO.DeleteFile sFileName, True
	End If
	Set objFSO = Nothing
	Set oJob = Nothing

End Function