﻿USE [FabApprovalSystem]
GO
	/****** Object:  UserDefinedFunction [dbo].[fnPartsRequestGetSubRolesForNextStep]    Script Date: 11/21/2024 11:31:55 AM ******/
SET
	ANSI_NULLS ON
GO
SET
	QUOTED_IDENTIFIER ON
GO
	CREATE FUNCTION [dbo].[fnPartsRequestGetSubRolesForNextStep] (@PRNumber int) RETURNS varchar(100) AS BEGIN DECLARE @NextStep int = 0 DECLARE @r varchar(100)
SELECT
	@NextStep = CurrentStep + 1
FROM
	PartsRequest
WHERE
	PRNumber = @PRNumber
SET
	@r = CASE
		WHEN @NextStep = 1 THEN 'Part Assignment'
		WHEN @NextStep = 2 THEN 'Pre-Approver'
		WHEN @NextStep = 3 THEN 'Tech Lead'
		WHEN @NextStep = 4 THEN 'Finance'
		WHEN @NextStep = 5 THEN 'SAP'
		WHEN @NextStep = 6 THEN 'Source List & Info Record'
		WHEN @NextStep = 7 THEN 'Buyer/Planner'
		WHEN @NextStep = 8 THEN 'Close to Folder'
		ELSE 'Part Assignment'
	END RETURN @r
END
GO