UFN_CONSTITUENT_GETMOSTRECENTLYCHANGEDRECOGNITIONPROGRAM
Returns the most recently changed recognition program for a constituent.
Return
| Return Type |
|---|
| table |
Parameters
| Parameter | Parameter Type | Mode | Description |
|---|---|---|---|
| @CONSTITUENTID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_CONSTITUENT_GETMOSTRECENTLYCHANGEDRECOGNITIONPROGRAM
(
@CONSTITUENTID uniqueidentifier
)
returns table
as
return
(
select top 1
RECOGNITIONPROGRAM.NAME as RECOGNITIONPROGRAM,
RECOGNITIONLEVEL.NAME as RECOGNITIONLEVEL
from dbo.CONSTITUENTRECOGNITION
inner join dbo.RECOGNITIONPROGRAM on CONSTITUENTRECOGNITION.RECOGNITIONPROGRAMID = RECOGNITIONPROGRAM.ID
inner join dbo.RECOGNITIONLEVEL on CONSTITUENTRECOGNITION.RECOGNITIONLEVELID = RECOGNITIONLEVEL.ID
where
CONSTITUENTRECOGNITION.CONSTITUENTID = @CONSTITUENTID and
-- Make sure the constituent is still active in this program
CONSTITUENTRECOGNITION.STATUSCODE = 0 and -- Active
CONSTITUENTRECOGNITION.EXPIRATIONDATE >= dbo.UFN_DATE_GETEARLIESTTIME(getdate())
order by CONSTITUENTRECOGNITION.DATECHANGED desc
)