-- ============================================================================= -- MENTITY.WORKFLOWTEMPLATE — centralize the workflow "particulars" display -- template on the entity itself, instead of MWORKFLOWCONFIG.PARTICULARSTEMPLATE. -- -- Why: MWORKFLOWCONFIG.PARTICULARSTEMPLATE is per CLIENTID+ENTITYID+WORKFLOWID — -- an implementation-side config row that in practice never gets its template -- filled in on any client DB (confirmed: zero PARTICULARSTEMPLATE values found -- anywhere in the GB5Framework repo). The template text only depends on the -- entity's DataJson shape (a framework/dev-time concern), not on the client, so -- it belongs on MENTITY (one row per entity, already mandatory) instead of a -- per-client config table nobody populates. -- -- Rollout is additive and backward compatible: WorkFlowQB.cs's four display -- queries now read COALESCE(WC.PARTICULARSTEMPLATE, ME.WORKFLOWTEMPLATE) — any -- client that already set a PARTICULARSTEMPLATE override in MWORKFLOWCONFIG -- keeps using it unchanged; everyone else now gets this default for free. -- SQL Server only (matches every other migration in this family). -- ============================================================================= IF NOT EXISTS ( SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'MENTITY' AND COLUMN_NAME = 'WORKFLOWTEMPLATE' ) BEGIN ALTER TABLE MENTITY ADD WORKFLOWTEMPLATE NVARCHAR(MAX) NULL; END GO -- Seed: templates for the entities that currently run through workflow approval. -- ENTITYID values confirmed live on unisoftgb4 (2026-09-03): TASK, TLEAVE, TIMESLIP. UPDATE MENTITY SET WORKFLOWTEMPLATE = N'DTO.DataJson.TaskNumber - DTO.DataJson.TaskTaskName - DTO.DataJson.TaskPlannedHours - DTO.DataJson.TaskDateOnly' WHERE ENTITYID = -1899999523; -- TASK GO UPDATE MENTITY SET WORKFLOWTEMPLATE = N'DTO.DataJson.TLeaveType / DTO.DataJson.TLeaveLeaveNumber / DTO.DataJson.TLeaveDetailArray.EmployeeCode / DTO.DataJson.TLeaveDetailArray.EmployeeName / DTO.DataJson.TLeaveNumberOfDays day(s) / DTO.DataJson.TLeaveDetailArray.FromDate to DTO.DataJson.TLeaveDetailArray.ToDate / DTO.DataJson.TLeaveRemarks / Balance Leave: DTO.DataJson.TLeaveDetailArray.LeaveBalance' WHERE ENTITYID = -1399999827; -- TLEAVE GO UPDATE MENTITY SET WORKFLOWTEMPLATE = N'Permission Request / DTO.DataJson.EmployeeCode / DTO.DataJson.EmployeeName / DTO.DataJson.DepartmentName / DTO.DataJson.TimeSlipAttendanceDate / DTO.DataJson.TimeSlipDurationString / DTO.DataJson.TimeSlipTimeSlipStartTimeString to DTO.DataJson.TimeSlipTimeSlipEndTimeString / DTO.DataJson.TimeSlipReason' WHERE ENTITYID = -1399999744; -- TIMESLIP GO -- ============================================================================= -- END OF MIGRATION 20260903_MEntity_WorkflowTemplate_Column (SQL Server) -- =============================================================================