Resetting Workflow State Names on All Class Tables

This example demonstrates how to update class tables when the name of a workflow state is changed in M-Files.

Check Workflow State in SQL

SELECT *
FROM dbo.MFWorkflowState AS mws
INNER JOIN dbo.MFWorkflow AS mw ON mw.ID = mws.MFWorkflowID;

Update Metadata

EXEC dbo.spMFDropAndUpdateMetadata @IsStructureOnly = 0;

Recheck Workflow State Table in SQL

EXEC dbo.spMFSynchronizeSpecificMetadata @Metadata = 'States', @IsUpdate = 0, @ItemName = NULL, @Debug = 0;
--or
EXEC dbo.spMFSynchronizeMetadata;

Update Class Table with State Change

SELECT class
FROM dbo.MFvwMetadataStructure AS mfms
INNER JOIN dbo.MFWorkflow AS mw ON mfms.Workflow_MFID = mw.MFID
INNER JOIN dbo.MFWorkflowState AS mws ON mws.MFWorkflowID = mw.ID
WHERE mws.IsNameUpdate = 1
GROUP BY mfms.Class;

EXEC dbo.spMFCreateTable @ClassName = 'Contract or Agreement', @Debug = 0;
EXEC dbo.spMFUpdateTable @MFTableName = 'MFcontractorAgreement', @UpdateMethod = 1;

Check Workflow State Name Change

SELECT Workflow_State FROM MFcontractorAgreement;

Update All State Label Changes

DECLARE @ProcessBatch_id INT;
EXEC dbo.spmfSynchronizeWorkFlowSateColumnChange @TableName = 'MFContractorAgreement',
                                                @ProcessBatch_id = @ProcessBatch_id OUTPUT,
                                                @Debug = 1;
--or
EXEC dbo.spmfSynchronizeWorkFlowSateColumnChange;