UFN_SECURITY_APPUSER_GRANTED_BATCHWORKFLOWTASK

Returns true if user has been granted and not denied rights for a batch workflow state given a workflow task.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@APPUSERID uniqueidentifier IN
@BATCHWORKFLOWTASKID uniqueidentifier IN

Definition

Copy


create function dbo.UFN_SECURITY_APPUSER_GRANTED_BATCHWORKFLOWTASK
(@APPUSERID uniqueidentifier,@BATCHWORKFLOWTASKID uniqueidentifier)
returns bit
as
/*
Returns true if user has been granted and not denied rights for a batch workflow state.
*/
begin
    --If at least one grant and no deny then return true

    --otherwise, false

    declare @grant bit;
    set @grant=0;

    select @grant = ISSYSADMIN from dbo.APPUSER where ID = @APPUSERID;

    if @grant = 0
        begin
            --order by GRANTORDENY, deny will be first.

            select top 1 @grant=GRANTORDENY
                from dbo.V_SECURITY_SYSTEMROLEASSIGNMENT_USER_BATCHWORKFLOWSTATE                            
                with (NOEXPAND, INDEX(IX_V_SECURITY_SYSTEMROLEASSIGNMENT_USER_BATCHWORKFLOWSTATE_BATCHWORKFLOWSTATEID_APPUSERID))
                inner join BATCHWORKFLOWTASK on BATCHWORKFLOWTASK.NEXTBATCHWORKFLOWSTATEID = V_SECURITY_SYSTEMROLEASSIGNMENT_USER_BATCHWORKFLOWSTATE.BATCHWORKFLOWSTATEID
                where BATCHWORKFLOWTASK.ID = @BATCHWORKFLOWTASKID and V_SECURITY_SYSTEMROLEASSIGNMENT_USER_BATCHWORKFLOWSTATE.APPUSERID = @APPUSERID                            
                order by GRANTORDENY ASC;                        
        end

    return @grant;

end