Destroy Object Versions in M-Files
This example demonstrates how to use spMFGetHistory to list object versions and spMFDeleteObject to destroy specific versions (not the latest).
List Object Versions
SELECT * FROM dbo.MFClass AS mc;
SELECT mcoa.MFVersion, mcoa.ObjID, mcoa.Name_Or_Title FROM dbo.MFCustomer AS mcoa;
EXEC spmfupdatetable 'MFCustomer', 1;
Get Version History
UPDATE mcoa
SET mcoa.Process_ID = 5
FROM dbo.MFCustomer AS mcoa
WHERE mcoa.ObjID = 134;
DECLARE @Update_ID INT, @ProcessBatch_id INT;
EXEC dbo.spMFGetHistory @MFTableName = 'MFCustomer',
@Process_id = 5,
@ColumnNames = 'MF_Last_modified',
@IsFullHistory = 1,
@NumberOFDays = NULL,
@StartDate = NULL,
@Update_ID = @Update_ID OUTPUT,
@ProcessBatch_id = @ProcessBatch_id OUTPUT,
@Debug = 0;
SELECT * FROM dbo.MFObjectChangeHistory AS moch WHERE moch.ObjID = 134;
Delete a Specific Version
DECLARE @Output NVARCHAR(2000);
DECLARE @processBatch_ID INT;
DECLARE @Return_Value INT;
EXEC @Return_Value = dbo.spMFDeleteObject @ObjectTypeId = 136,
@objectId = 134,
@Output = @Output OUTPUT,
@ObjectVersion = 9,
@DeleteWithDestroy = 1,
@ProcessBatch_id = @processBatch_ID OUTPUT;
SELECT @Return_Value;
SELECT * FROM dbo.MFProcessBatchDetail AS mpbd WHERE mpbd.ProcessBatch_ID = @ProcessBatch_ID;