You need to sign in to do that
Don't have an account?
File Attachment in Knowledge Articles
I would like to pull the URL for the File Attachment in my Knowledge Article, is this possible? In my article type i created a data Type for File Attachment called TestImage, but unfortunately I'm unable to figure out to retrieve this URL.
I am implemententing a custom Visualforce page for Knowledge. Any assistance would be appreciated. Thanks
I am implemententing a custom Visualforce page for Knowledge. Any assistance would be appreciated. Thanks
I tried this work around, but it takes extra steps and the user's didn't feel it was necessary. I did manage to find another work around where we used the RTF field and allow insert article image. Then I create a formula to retrieve the SRC URL of the image.
All Answers
However, you can try following as a workaround: use an Object that refers to the File attached to the Article and populate the URL with Outputlink , after implementing that in VF page , you should be able to get the link for downloading the file attached to the Article
Read more: https://help.salesforce.com/apex/HTViewHelpDoc?id=knowledge_article_templates_custom.htm&language=en
I tried this work around, but it takes extra steps and the user's didn't feel it was necessary. I did manage to find another work around where we used the RTF field and allow insert article image. Then I create a formula to retrieve the SRC URL of the image.
I'm trying to do the same thing, so I put an image into the Rich Text Field, however, when I viewed the source, the image URL was as follows:
https://c.cs7.content.force.com/servlet/rtaImage?eid=ka0M00000008TYt&feoid=00NC0000005GaEm&refid=0EMM00000008Z4b
However, the URL for the Attachment is: https://c.cs7.content.force.com/servlet/fileField?id=0BEM00000004D3z
I see no way to scrape that FileField id out of the Image SRC URL. Please kindly elaborate on your solution.
Thanks!
DaveS
I have tried with
<apex:outputLink value="{!URLFOR($Action.Training_Courses__kav.FileFieldDownload, Training_Courses__kav.id, ['field'=$ObjectType.Training_Courses__kav.fields.Attachment__s.name])}">Click me</apex:outputLink>
But i am getting the error as: Error: Unknown property '$ObjectType.Training_Courses__kav.fields.Attachment__s'
i have refered this from link:
https://help.salesforce.com/apex/HTViewHelpDoc?id=knowledge_article_templates_custom.htm&language=en
Please tell me what i did mistake here
Full credit is to be given to the poster on that one. Here is a code snippet in case that post is ever deleted.
Simply replace "FAQ__kav" with the name of your Article Type and "Attachment_1" with the field name assigned to the Attachment within that Article Type.
Works like a charm!
Hi,
I tried above it does not work for File Field type on article. Below is the url format for getting a URL for File Field which redirects to its actual URL of File provided by Salesforce when an attachment is openend from Article, having Id prefix '0BE'
<a href="'/servlet/fileField?entityId='+Article_Type__kav.Id+'&common.udd.actions.ActionsUtilORIG_URI=%2Fservlet%2FfileField&field=MyFile__Body__s'">Click Me</a>
Above is the only way to use it in Lightning where URLFOR cannot be used.
For using in Visualforce with URLFOR below can be used, with KnowledgeArticleId provided in page url
<apex:outputLink value="{!URLFOR($Action.Article_Type__kav.FileFieldDownload, Article_Type__kav.id, ['field'=$ObjectType.Article_Type__kav.fields.MyFile__Body__s.name])}">Click me</apex:outputLink>
Without URLFOR in visualforce same can be used
<a href="'/servlet/fileField?entityId='+Article_Type__kav.Id+'&common.udd.actions.ActionsUtilORIG_URI=%2Fservlet%2FfileField&field=MyFile__Body__s'">Click Me</a>
And this works :)
With Lightning and VF, we would usually have an apex controller so, it is easier to the use the URL class (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_url.htm) to get the FilesURL using apex. You can use the method getFileFieldURL(entityId, fieldName).
Note: Here the fieldName is the Body subfield of the FileField. i.e. If the File_1__c is the custom file field the body field name is File_1__Body__s.
e.g. String fileURL = URL.getFileFieldURL('KAV.Id','File_1__Body__s');
the output is something is as below
https://myorg.c.cs14.content.force.com/servlet/fileField?entityId=KAV.Id&field=File_1__Body__s