Workflow and Event Handlers¶
Overview¶
Workflow (action types 4 & 5) and event handler integrations enable automation without manual user clicks. Items do not appear in the visible menu; they are invoked by scripts referencing the ActionName and ActionTypeID.
Action Type Selection¶
Use Type 4 when no object parameters are needed.
Use Type 5 when object metadata (ObjID, ObjVer, ClassID, ObjectType) must be supplied.
State Action Script (VBScript Example)¶
Replace StateAction2
with your ActionName and ensure matching row exists in MFContextMenu with ActionTypeID = 5.
Option Explicit
Dim ClassID
ClassID = Vault.ObjectPropertyOperations.GetProperty(ObjVer, 100).Value.GetLookupID
Dim strInput
strInput = "{""ObjectID"": " & ObjVer.ID & ", ""ObjectType"": " & ObjVer.Type & ", ""Objectver"": " & ObjVer.Version & ", ""ClassID"": " & ClassID & ", ""ActionName"": ""StateAction2"", ""ActionTypeID"": ""5""}"
Dim strOutput
strOutput = Vault.ExtensionMethodOperations.ExecuteVaultExtensionMethod("PerformActionMethod", strInput)
' Optionally raise message / cancel based on strOutput
Event Handler Script¶
Embed similar logic in event handler (OnCheckInChanges / AfterCheckInChanges etc.) to start processes on system events (ensure idempotency to avoid loops).
Procedure Pattern¶
Action type 5 procedure signature example:
CREATE OR ALTER PROCEDURE custom.StateAction_VendorApproved
@ID INT,
@Output VARCHAR(1000) OUTPUT,
@ObjectID INT,
@ObjectType INT,
@ObjectVer INT,
@ClassID INT
AS
BEGIN
SET NOCOUNT ON;
-- Logging scaffold (ProcessBatch start)
-- Business logic (e.g., sync vendor row) here
SET @Output = 'Vendor approval action queued.';
END;
Idempotency & Re-Entrancy¶
Use guards to prevent duplicate processing:
IF EXISTS (SELECT 1 FROM dbo.CustomVendorSyncAudit WHERE ObjectID=@ObjectID AND Status='SUCCESS')
BEGIN
SET @Output='Already processed';
RETURN;
END;
Error Handling¶
Capture exceptions; set @Output to short, user-safe message.
Write full diagnostics to ProcessBatchDetail for administrators.
Testing Checklist¶
Create MFContextMenu row (Type 5) referencing procedure.
Add script to workflow state; publish changes.
Transition object; confirm ProcessBatch entries.
Validate @Output surfaced (if synchronous) or later log message.
Cross References¶
Queue & Logging: queue-and-logging
Creation Helpers: Creating Menu Items