web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

How to retrieve knowledge base articles and its attachments to Power Pages?

(1) ShareShare
ReportReport
Posted on by 587
Hi,
     I have been working on the retrieving knowledge base article along with its attachments. I can be able to fetch the knowledge article content, but I could not be able to fetch its attachments. I have used fetch xml to accomplish this.
 
    For fetching attachments, I have tried to fetch the attachments of knowledge article from annotations table by filtering the objecttypecode eq 'knowledgearticle'. I need to get the base64 content of the attachment so that i can add that as a downloadable file in the portal. The filter will be like below.

https://<orgnamexyz123>.crm.dynamics.com/api/data/v9.2/annotations?$filter=objecttypecode eq 'knowledgearticle'
 
But I couldn't get results, and it returns an empty array. Are there any configurations behind this to fetch the attachment value from the D365 CRM Web API.

Any help or suggestions or other workaround on this would be much appreciated.
 
 
 
Thanks,
Tamilarasu Arunachalam
I have the same question (0)
  • Suggested answer
    Muhammad.Affan Profile Picture
    4,624 Super User 2025 Season 2 on at
    Hi There,

    Refer to these links: 
    https://learn.microsoft.com/en-us/dynamics365/customer-service/administer/set-up-knowledge-management-embedded-knowledge-search#update-knowledge-article-attachments-for-portal

    https://community.dynamics.com/forums/thread/details/?threadid=c66cee9f-a99b-4ebd-be11-6e4959d9c4c9


    Finally, once your issue is resolved and my suggested answer has helped, please do not forget to click Yes under "Did this answer your question?" to close this thread.

    Thanks
    Affan
    Follow my channel related to Dynamics 365:  https://www.youtube.com/@AffansDynamicsJourney
     
     
  • Suggested answer
    Sachin Jadhav Profile Picture
    157 on at
    Hi,
     
    • Attachments added on Knowledge article(knowledgearticle) are stored in entity msdyn_kbattachment 
    • The relationship between knowledgearticle and msdyn_kbattachment is M:M (msdyn_msdyn_kbattachment_knowledgearticle) 
    • The actual file content that is the base 64 file itself is then stored in fileattachment table with objecttypecode and objectid pointing to msdyn_kbattachment table
     
    So if you have knowledgearticleid for knowledgearticle table, you can retrieve related attachments as follows.
     
    Fetch Query:-
     
    <fetch>
      <entity name="knowledgearticle">
        <attribute name="knowledgearticleid" />
        <filter>
          <condition attribute="knowledgearticleid" operator="eq" value="32b90f18-abf7-ea11-a815-000d3a1b14a2" />
        </filter>
        <link-entity name="msdyn_msdyn_kbattachment_knowledgearticle" from="knowledgearticleid" to="knowledgearticleid" intersect="true">
          <link-entity name="msdyn_kbattachment" from="msdyn_kbattachmentid" to="msdyn_kbattachmentid" alias="ka">
            <attribute name="msdyn_filename" />
            <attribute name="msdyn_filetype" />
            <attribute name="msdyn_filesize" />
            <link-entity name="fileattachment" from="fileattachmentid" to="msdyn_fileattachment" link-type="outer" alias="fa">
              <attribute name="body" />
            </link-entity>
          </link-entity>
        </link-entity>
      </entity>
    </fetch>
     
    ODATA 4.0 (WebAPI equivalent query):-
     
    https://<orgid>.crm8.dynamics.com/api/data/v9.2/knowledgearticles?$select=knowledgearticleid&$expand=msdyn_msdyn_kbattachment_knowledgearticle($select=msdyn_filename,msdyn_filetype,msdyn_filesize;$expand=msdyn_fileattachment($select=body))&$filter=(knowledgearticleid eq 32b90f18-abf7-ea11-a815-000d3a1b14a2) and (msdyn_msdyn_kbattachment_knowledgearticle/any(o1:(o1/msdyn_kbattachmentid ne null)))
     
     
    If this answers your question, please accept the same

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 61

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 52 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans