Hi All, I have been trying to do this creating this code in the AfterCheckinChangesFinalize EventHandler, unfortunatelly does not matter the adjustments to the code I Receive an error message.
The Issue is that for some documents of the same class the user want to select the process and the Metadata card configuration, so adding a property I can let them select, change the metadatacard configuration based on this property in the filter and based on the same property using the event handler I want to change the workflow and the state.
the permanent error is:
-The Value "8 - 0" does not exist, or it is a conflict object-
The code as follow:
Option Explicit 'move a document from it's actual WF and move it to another WF depending of I_OLD_DOC_PROP lo mueve al antiguo flujo de trabajo Const I_MC_OLD_WF = 131 'Old Document Format WorkFlow Const I_MC_CLASS = 1015 'Affected Class Const I_OLD_DOC_PROP = 1233 'Is Old or New Document Property Dim iStatus, iClass, iWFState, iTargetWFS Dim oPropertyValues: Set oPropertyValues = CreateObject( "MFilesAPI.PropertyValues" ) Set oPropertyValues = Vault.ObjectPropertyOperations.GetProperties( ObjVer ) Dim oWorkflowState: Set oWorkflowState = CreateObject( "MFilesAPI.ObjectVersionWorkflowState" ) iStatus = oPropertyValues.SearchForProperty( I_OLD_DOC_PROP ).TypedValue.GetLookupID iClass = oPropertyValues.SearchForProperty( MFBuiltInPropertyDefClass ).TypedValue.GetLookupID iWFState = oPropertyValues.SearchForProperty( MFBuiltInPropertyDefState ).TypedValue.GetLookupID Dim oObjVer: Set oObjVer = CreateObject( "MFilesAPI.ObjectVersion" ) Set oObjVer = Vault.ObjectOperations.GetLatestObjVer( ObjVer.ObjID, False, False ) If iClass = I_MC_CLASS And iStatus = 1 Then 'If Old Format document Select Case iWFState 'move to the correct State in the new workflow depending on the actual state Case 102 : iTargetWFS = 499 Case 103 : iTargetWFS = 500 End Select 'If not CheckedOut, CheckOut and apply changes, then CheckIn ' If Not Vault.ObjectOperations.IsCheckedOut( oObjVer.ObjID ) Then 'Checkout object and Change WF and State Dim oCheckedOut ': Set oCheckedOut = CreateObject( "MFilesAPI.ObjectVersion" ) Set oCheckedOut = Vault.ObjectOperations.CheckOut( ObjVer.ObjID ) ' Vault.ObjectOperations.CheckOut ObjVer oWorkflowState.Workflow.TypedValue.SetValue MFDatatypeLookup, I_MC_OLD_WF oWorkflowState.State.TypedValue.SetValue MFDatatypeLookup, iTargetWFS oWorkflowState.VersionComment.TypedValue.SetValue MFDatatypeMultiLineText, "Generado automáticamente por M-Files desde Documento antiguo" Vault.ObjectPropertyOperations.SetWorkflowState oCheckedOut.ObjVer, oWorkflowState 'CheckIn Vault.ObjectOperations.CheckIn oCheckedOut.ObjVer ' Else ' Err.Raise MFScriptCancel, "El objeto se encuentra protegido" ' End If 'NOT IsCheckedOut End If 'iClass and iStatus
Any idea?