Ruslan_Rayanov

as_en_getAvailableStatusesForInstance

Apr 4th, 2025
3,185
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.98 KB | None | 0 0
  1. CREATE PROCEDURE [dbo].[as_en_getAvailableStatusesForInstance]
  2.     @entityCode nvarchar(256),
  3.     @instanceID int,   
  4.     @username nvarchar(32)
  5. AS
  6. BEGIN
  7.     declare @langID int = (select langID from as_users where username = @username)
  8.     execute as_print  @langID
  9.     select *, s.id StatusID ,
  10.     (case isnull(buttonTitle,'')
  11.      when '' then isnull(ls.name, s.name )    
  12.      else buttonTitle end
  13.     ) Name
  14.     from as_en_availableStatuses avs
  15.         inner join as_en_statuses s on s.id = avs.availableStatusID
  16.         left join [as_lang_statuses] ls on ls.itemID =s.id  and langID = @langID
  17.     where
  18.         currentStatusID in (select statusID from as_en_entityInstances
  19.                             where id = @instanceID and entityID in (select id from as_en_entities
  20.                                                                     where code = @entityCode)
  21.         )
  22.         and ( ( isnull(users, '') ='' and isnull(roles, '') ='' ) or dbo.sec_hasAccessByUsersRoles(@username, users, roles) = '1')
  23.     order by avs.ord, s.ord
  24.  
  25. END
Advertisement
Comments
Add Comment
Please, Sign In to add comment