USE [FabApprovalSystem] GO /****** Object: UserDefinedFunction [dbo].[fn_Get8DAuditByUser] Script Date: 11/21/2024 11:31:55 AM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATE FUNCTION [dbo].[fn_Get8DAuditByUser] ( -- Add the parameters for the function here @UserID INT ) RETURNS TABLE AS RETURN ( -- Add the SELECT statement with parameter references here -- M_Suffix SELECT DISTINCT 'Audit' AS DocumentType, 'Audit' AS SubDoc, * FROM ( SELECT DISTINCT A.AuditNo as IssueID, A.AuditNo DocID, A.AuditDate, '' AS LotNos, '' AS 'PendingApprovers', A.AuditTitle AS Title, '' AS IssueDescription, U2.FirstName + ' ' + U2.LastName AS Originator, A.AuditDate SubmitedDate, NULL AS CloseDate, '' AS ItemStatus, NULL AS NextDueDate FROM _8DAudit A INNER JOIN Users U2 ON A.OriginatorID = U2.UserID WHERE A.OriginatorID = @UserID AND (A.AuditStatus = 0) ) AS A ) GO