fnGetUserIDFromLinkedRecordID
Return
Return Type |
---|
int |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@RecordID | int | IN | |
@BackOfficeSystemID | int | IN |
Definition
Copy
CREATE FUNCTION [dbo].[fnGetUserIDFromLinkedRecordID](@RecordID int, @BackOfficeSystemID int)
RETURNS int AS
BEGIN
DECLARE @UserID int
SELECT TOP 1 @UserID = coalesce(cu.ID, 0) FROM dbo.ClientUsers cu inner join dbo.BackOfficeSystemUsers bosu on cu.id=bosu.clientusersid
inner join dbo.BackOfficeSystemPeople bosp on bosu.backofficepeopleID=bosp.id and bosp.BackofficeSystemID=@BackOfficeSystemID and bosp.[BackOfficeRecordID] = @RecordID
where CU.deleted=0 and bosu.[Current] = 1
ORDER BY cu.[ID] desc
return @UserID
END