UFN_SECURITY_APPUSER_GRANTED_BATCHWORKFLOWSTATE

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

Return

Return Type
bit

Parameters

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

Definition

Copy


            create function dbo.UFN_SECURITY_APPUSER_GRANTED_BATCHWORKFLOWSTATE
            (@APPUSERID uniqueidentifier,@BATCHWORKFLOWSTATEID 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))                            
                            where V_SECURITY_SYSTEMROLEASSIGNMENT_USER_BATCHWORKFLOWSTATE.APPUSERID = @APPUSERID and
                            V_SECURITY_SYSTEMROLEASSIGNMENT_USER_BATCHWORKFLOWSTATE.BATCHWORKFLOWSTATEID = @BATCHWORKFLOWSTATEID
                            order by GRANTORDENY ASC;                        
                    end

                return @grant;

            end