UFN_PDACCOUNTSYSTEM_SITESTRING_FORSOURCERECORD
Return a list of site names associated with this Accounting System.
Return
Return Type |
---|
nvarchar(max) |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@PDACCOUNTSYSTEMID | uniqueidentifier | IN | |
@CURRENTAPPUSERID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_PDACCOUNTSYSTEM_SITESTRING_FORSOURCERECORD
(
@PDACCOUNTSYSTEMID uniqueidentifier,
@CURRENTAPPUSERID uniqueidentifier
)
returns nvarchar(max)
with execute as caller
as begin
declare @retString nvarchar(max)
declare @tempSite table (siteName nvarchar(255))
insert into @tempSite (siteName)
select '<No Site>' from
dbo.PDACCOUNTSYSTEM
where ID = @PDACCOUNTSYSTEMID and isdefault = 1
insert into @tempSite (siteName)
select T1.Name from dbo.SITE T1
inner join dbo.PDACCOUNTSYSTEMSITE T2 on T1.ID = T2.SITEID
inner join dbo.UFN_SITESFORUSER(@CURRENTAPPUSERID) T3 on T1.ID = T3.SITEID
where T2.PDACCOUNTSYSTEMID = @PDACCOUNTSYSTEMID
select @retString = isnull(@retString+', ','') + siteName
from @tempSite
return @retString
end