I have an apex repeat which I want to use to add an dynamic id at the end of the URLFOR but get an syntax error what is wrong with my annotation


<apex:repeat value="{!idsContentdocument}" var="file">
    <a href="{!URLFOR('/sfc/servlet.shepherd/document/download/'+{!file.ContentDocumentId})}" target="_blank"> Click here </a>&nbsp;&nbsp;&nbsp;
  • 2
    I think it may be the ! in {!file.ContentDocumentID}. Try removing that and see if that works. As -- {!URLFOR('.....' + file.ContentDocumentId)} – Jayant Das May 1 '19 at 15:54
  • @JayantDas So simple but it was the solution. Thx please refer as answer. – Thomas May 1 '19 at 15:58

Rolling up from comments.

You don't need to refer ! in {!file.ContentDocumentID}. Removing that should work.

<a href="{!URLFOR('/sfc/servlet.shepherd/document/download/' + file.ContentDocumentId)} ..>
  • Could you please explain on what the 5 dots mean here? – Raul May 1 '19 at 16:57
  • @Raul those were just a representation of what is already in there. Let me update it with existing values as in the question to make sure there's no confusion. – Jayant Das May 1 '19 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.