UFN_NOTIFICATION_RECORDHASNOTIFICATIONS
Determine whether or not the given record has any annotations or notifications.
Return
Return Type |
---|
bit |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@RECORDID | uniqueidentifier | IN | |
@RECORDTYPEID | uniqueidentifier | IN | |
@CURRENTAPPUSERID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_NOTIFICATION_RECORDHASNOTIFICATIONS
(
@RECORDID uniqueidentifier,
@RECORDTYPEID uniqueidentifier,
@CURRENTAPPUSERID uniqueidentifier
)
returns bit
as
begin
declare @RECORDHASNOTIFICATIONS bit
set @RECORDHASNOTIFICATIONS =
case
when exists(
select top 1 ID from UFN_NOTIFICATION_GETRECORDNOTIFICATIONS (@RECORDTYPEID,@RECORDID,@CURRENTAPPUSERID)
) --Record has system notifications the current user can see.
then
1
when @CURRENTAPPUSERID is null then --Short circuit so function call doesn't error
0
when exists(
select ID
from dbo.[UFN_ANNOTATION_GETRECORDANNOTATIONS](@RECORDTYPEID,@RECORDID,@CURRENTAPPUSERID)
) --Record has annotations the current user can see.
then
1
else
0
end
return @RECORDHASNOTIFICATIONS
end