1

I have attachment Id and I need the URL for that particular attachment. Right now In visualforce we have {!URLFOR($Action.Attachment.Download, attachmentId)} to get the URL.

But In my LWC component I am constructing the URL programmatically like:

url = `/servlet/servlet.FileDownload?file=${attachmentId}`

I want to avoid harcoding the first part of the string /servlet/servlet.FileDownload.. Is there anything similar in LWC that we can use to get the URL directly

3

No, but... You could call Url.getFileFieldURL in Apex to resolve the URL you need, then link to that dynamically in LWC.

| improve this answer | |

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.