Friday, July 7, 2017

Dynamics GP - Workflow Tables and SQL View for approval status and approval steps status

https://community.dynamics.com/gp/b/dynamicsgp/archive/2015/08/04/workflow-2-0-tables-what-each-one-does-and-what-information-you-can-get-from-them-for-reporting-purposes

  • WFI10002 - Status of each transaction in Workflow
--SQL View to convert Status
-------------------------------------------------------------------------------------------------------

CREATE VIEW [dbo].[BI_WorkflowDesc]
AS
SELECT DISTINCT
                         WfBusObjKey, Workflow_Status,
                         CASE WHEN WFI10002.workflow_status = 1 THEN '1- Not Submitted' WHEN WFI10002.workflow_status = 2 THEN '2- Submitted (Deprecated)' WHEN WFI10002.workflow_status = 3 THEN '3- No Action Needed' WHEN
                          WFI10002.workflow_status = 4 THEN '4- Pending User Action' WHEN WFI10002.workflow_status = 5 THEN '5- Recalled' WHEN WFI10002.workflow_status = 6 THEN '6- Completed' WHEN WFI10002.workflow_status
                          = 7 THEN '7- Rejected' WHEN WFI10002.workflow_status = 8 THEN '8- Workflow Ended (Depricated)' WHEN WFI10002.workflow_status = 9 THEN '9- Not Activated' WHEN WFI10002.workflow_status = 10 THEN '10- Deactivated (Depricated)'
                          END AS WFDesc, Workflow_Description
FROM            dbo.WFI10002


GO

-----------------------------------------------------------------------------------------------------
--SQL View to show all Steps required in multi-step workflow
-----------------------------------------------------------------------------------------------------
/****** Object:  View [dbo].[BI_WorkFlowStepsDesc]    Script Date: 7/19/2017 9:48:16 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE VIEW [dbo].[BI_WorkFlowStepsDesc]
AS
SELECT DISTINCT
                         dbo.WFI10002.WfBusObjKey, dbo.WFI10002.Workflow_Status,
                         CASE WHEN WFI10002.workflow_status = 1 THEN '1- Not Submitted' WHEN WFI10002.workflow_status = 2 THEN '2- Submitted (Deprecated)' WHEN WFI10002.workflow_status = 3 THEN '3- No Action Needed' WHEN
                          WFI10002.workflow_status = 4 THEN '4- Pending User Action' WHEN WFI10002.workflow_status = 5 THEN '5- Recalled' WHEN WFI10002.workflow_status = 6 THEN '6- Completed' WHEN WFI10002.workflow_status
                          = 7 THEN '7- Rejected' WHEN WFI10002.workflow_status = 8 THEN '8- Workflow Ended (Depricated)' WHEN WFI10002.workflow_status = 9 THEN '9- Not Activated' WHEN WFI10002.workflow_status = 10 THEN '10- Deactivated (Depricated)'
                          END AS WFDesc, dbo.WFI10002.Workflow_Description, dbo.WFI10003.Workflow_Step_Name,
                         CASE WHEN WFI10003.workflow_step_status = 1 THEN '1- No Action Needed' WHEN WFI10003.workflow_step_status = 2 THEN '2- Pending User Action' WHEN WFI10003.workflow_step_status = 3 THEN '3- Rejected'
                          WHEN WFI10003.workflow_step_status = 4 THEN '4- Completed' WHEN WFI10003.workflow_step_status = 5 THEN '5- Recalled' WHEN WFI10003.workflow_step_status = 6 THEN '6- Failed' END AS WFStepDesc
FROM            dbo.WFI10003 RIGHT OUTER JOIN
                         dbo.WFI10004 ON dbo.WFI10003.WorkflowStepInstanceID = dbo.WFI10004.WorkflowStepInstanceID RIGHT OUTER JOIN
                         dbo.WFI10002 ON dbo.WFI10004.WorkflowInstanceID = dbo.WFI10002.WorkflowInstanceID


GO


No comments:

Post a Comment