Reputation: 69
I have created an SSRS Report which has a column named Attachment
which I want to display a link that, when clicked downloads the appropriate attachment
I have used this procedure which is accepting different parameters:
alter proc [dbo].[getLessonLearntDetails_New_Test]
@AssetID nvarchar(50),
@DepartmentID varchar(50),
@Category varchar(50),
@AuditType varchar(50),
@AuditStartYear nvarchar(50),
@AuditEndYear nvarchar(50)
as
begin
select row_number() over(order by AssetName asc) as Sno
,LLD.LessonComputedID
,tbl_Asset.AssetName
,AT.AuditType
,SY.Year+' - '+EY.Year as 'Audit Period'
,DE.DepartmentName
,CT.CategoryName
,LLD.Learnings
,LLD.RepeatedObservationReference
,Att.Attachment
from tbl_LessonLearntDetails as LLD
inner join tbl_Category as CT
on CT.CategoryID = LLD.Title
inner join tbl_Asset
on LLD.AssetID = tbl_Asset.AssetID
inner join tbl_Department as DE
on LLD.DepartmentID = DE.DepartmentID
inner join tbl_AuditType as AT
on LLD.AuditTypeID = AT.AuditTypeID
inner join tbl_Attachment as Att
on LLD.LessonLearntID = Att.LeassonLearntID
inner join tbl_AuditYear as SY
on SY.Year = LLD.AuditStartYear
inner join tbl_AuditYear as EY
on EY.Year = LLD.AuditEndYear
where ( (('0'=@AssetID and (1=1)) or LLD.AssetID=@AssetID) and
(('0'=@DepartmentID and (1=1)) or LLD.DepartmentID=@DepartmentID) and
(('0'=@Category and (1=1)) or LLD.Title=@Category) and
(('0'=@AuditType and (1=1)) or LLD.AuditTypeID=@AuditType) and
(('0'=@AuditStartYear and (1=1)) or (lld.AuditStartYear between @AuditStartYear and @AuditEndYear or lld.AuditEndYear between @AuditEndYear and @AuditStartYear) and
(('0'=@AuditEndYear and (1=1)) or lld.AuditEndYear between @AuditEndYear and @AuditStartYear or lld.AuditEndYear between @AuditStartYear and @AuditEndYear))
)
end
Upvotes: 1
Views: 1828
Reputation: 56
I have just tested this solution after some experiments and it definitely works for me. I assume that you will have a "DisplayName" for your attachment and then the full path of the file and extension. Set your Textbox column to "DisplayName" of the attachment, then right click on the attachment Textbox, then -> Action -> "Go to URL" then on the expression type the following:
="javascript:void(window.open('" & Replace(Fields!AttachmentLink.Value, "", "\") & "','_blank'))"
This will download/open the file in a new tab.
Please see the below screenshot:
also, make sure to make the textbox look like a hyperlink.
Upvotes: 1
Reputation: 873
If it is a link openable by URL, you can go to Textbox Properties -> Action -> Go To URL -> Select URL and do an expression and put something like this in:
="javascript:void(window.open('" & Fields!GoToThisURL.Value & "', '_blank'))"
Fields!GoToThisURL.Value would be the full URL value you want to go to include the .pdf extension I would think.
Upvotes: 2