Attachment field is not being retrieved correctly

Farah El Agha asked on January 3, 2018 13:56

Hello, I have created a page type with a field called "PDF", and it holds the form control "Attachments", the problem is that i am having a hard time retrieving the attachment from the transformation, I am using this code:

 <a class="linkDownload" href="<%# GetAbsoluteUrl(GetAttachmentUrl(EvalText("AttachmentName", true), Eval("NodeAliasPath")), EvalInteger("AttachmentSiteID")) %>" target="_blank"><%# Localize("{$download$}") %>
 </a>

the link opens new page with 404 Error (File or directory not found), is the format that I am using correct?

Correct Answer

Prashant Verma answered on January 4, 2018 06:46

Hi Farah,

I am assuming your page type field called "PDF" having a data type = "Attachment" and form control = "Attachments" why to use data type as Attachment if you want to store multiple attachments. Do you want to store multiple PDF against that page ? if yes then refer this example to get desired output.

If you want to upload only single PDF against page so you can use

1. data type = "File" and form control = "Direct Upload"

How to read in transformation <%# GetFileUrl("FeatureFile") %>

2. data type = "Text" and form control = "File Selection"

How to read in transformation <%# Eval("FeatureFile") %>

3. data type = "Text" and form control = "Media Selection"

How to read in transformation <%# Eval("FeatureFile") %>

Thanks

Happy to help !

2 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.