Ad Code

How to export knowledge articles in salesforce lightning

Export knowledge articles in salesforce lightning

In this blog post, I will guide you through detailed steps to export the knowledge articles from the Salesforce lightning sandbox using the knowledge import/export tool hosted on the Heroku platform. Additionally, learn the manual export method using a data loader or workbench.

Before learning export, let us understand how the knowledge import works in the salesforce lightning.

Lightning knowledge is a different concept compared to other objects in the salesforce. You can only import articles with plain text fields by using data loader or workbench tools. In the case of articles with images and rich text area content, salesforce supports only .zip format to import the articles.

Salesforce article import format

We have a different set of files and folders to achieve import functionality, which is described in detail.

In the salesforce service cloud > go to setup > search with ‘Import articles’ and find the options to import the articles into the salesforce

Export knowledge articles in salesforce lightning 1

To support this import, we must create a .csv file, .properties file, and then a zip file. 

.csv file

Using a tool such as Microsoft Excel, create a CSV file with a row for each article and a column for each article field and data category.

Export knowledge articles in salesforce lightning 2

Add this CSV to Root_folder

In the case of rich text area fields with multi-media content, we need to create multiple subfolders.

Root_folder > create a folder with the name ‘data 

Every rich-text area field content must be stored in the HTML format and add the HTML file in the ‘data’ folder

Export knowledge articles in salesforce lightning 3
Under the data folder, we can create a folder img

If there is an image in the HTML content, we can store the images in the img folder and refer the path in the HTML.

Export knowledge articles in salesforce lightning 4

Related path of the HTML file is added in the CSV 

Export knowledge articles in salesforce lightning 5
Note that data and img subfolders are required in the case of rich-text area fields.

.properties file

Create a property file to specify import parameters such as the CSV separator, rich-text encoding, or character encoding. This is added to the root folder.

Export knowledge articles in salesforce lightning 6
Make sure you have all the files in a single folder as shown below

Export knowledge articles in salesforce lightning 7

zip file

Once you create the required files and folders, zip these files which are inside the root folder. When you import this .zip file, salesforce internally extracts the data, creates new articles, and maps data categories to them as defined in the CSV.

Remember to zip only the files inside the folder, do not zip the folder itself.

Check why the 
data category to article mapping is important in salesforce lightning   

Note: You can make use of record types to insert different article types by mentioning record type id for each record.

This is how import and zip format works in the salesforce lightning. In the next section, you will learn how to export the articles.

Different ways to export the knowledge articles from salesforce

Method 1: Using the Heroku app

A third-party tool that helps in exporting articles from any salesforce sandbox/production instance. This tool is hosted on the Heroku platform.

Launch and click ‘export knowledge articles to a file’

Enter the credentials and click on submit button

Select all the details in the form and click on submit. Articles will be exported and the link to download a zip file is sent to your mail-id.

Download the file attached with the notification mail.

As discussed in the ‘How to import the articles’ section, rich text area fields are in the HTML format and are inside the ‘data’ folder. Relative path ‘data/html_file_name’ is added in the CSV 
Export knowledge articles in salesforce lightning 8
Use this zip file and import articles into the required salesforce sandbox.

Please note that this tool is not officially supported by the salesforce. Hence, consider your organization's data security policies when working with the production knowledge articles.

Method 2: Manual - using data loader or workbench

Launch Data loaderSelect Export option > Enter credentials and login

Select show all salesforce objects option > select ‘knowledge__kav’ 

Mention the target path for extraction and click next

Click on Select all fields > Click Finish 

.CSV gets created in the target path

Create a folder and copy this .csv file

Create and add .properties file into the new folder

Zip the files and import them into any sandbox

The above steps work well when you have plain text fields in the knowledge object. In case there is any rich text area field with embedded images, you need to carry out extra steps.

Reason: when you export article data with any rich text area fields in the data loader or workbench, the field values will be in the HTML format. Images in the HTML code are linked to the static URLs of the source salesforce sandbox. If you import this in the destination sandbox without modifying it, the article field contains HTML code with images pointed to the source salesforce sandbox. Basically, it will not display the articles in the correct format.

For example, in my sandbox, I have created a resolution custom rich text area field and exported its data from the data loader. Notice HTML code for the rich text area resolution field in the CSV.

Export knowledge articles in salesforce lightning 9

If you import the above-shown CSV to any sandbox, the resolution field will have all the HTML content as text.

Let us see how you can modify the format.

Copy the HTML code from the resolution field, create a .html file with the copied code inside the data folder

Identify the image links in the HTML and Copy the images from the salesforce sandbox to the local folder data/img and update this relative path to the img tag in the HTML code.

Mention the HTML file path in the .csv field as shown below

Export knowledge articles in salesforce lightning 10
Repeat the same steps for all rich text area fields in the knowledge object.

Note: Rich text area fields can also contain plain text. Notice the second record in the above screenshot. After import, it will just add the field value as 'Test' for that article. 


You can also make use of workbench to export the articles from the sandbox

Login to

Click on Queries > SOQL Query 

Select an object as 'Knowledge__kav' and Click on Bulk CSV

In the SOQL Query box write a query with all required fields for article export

Export Articles from Salesforce lightning
Click on the File download icon to get the article list

Export Articles from Salesforce lightning

Data loader and workbench methods are cumbersome when articles have more images embedded and also when the article count is high. I recommend exporting the articles from the Heroku app when you have rich text area fields in the knowledge.  

Above mentioned steps work well for exporting articles from one salesforce sandbox to another.

Occasionally you may get a requirement to export articles from different applications like oracle knowledge base aka OKB, Microsoft Dynamics CRM, or SAP systems to the Salesforce. In this case, either you must go with manual steps or write a desktop application that extracts articles and converts them into the salesforce supported format.

Bonus: Steps for your reference to implement the article conversion logic in the java platform
  1. Create a sample java console application
  2. Write a script that creates three folders in the hierarchy as Articles_Folder > data > img in the C drive
  3. Connect to the OKB database and extract the articles into the application context
  4. Basically, OKB articles are in XML format. Iterate through each file to get the required fields.
  5. Write a script to create a .csv file with required columns and also a .properties file inside Articles_Folder. Create a configuration file in the project to define the mapping between the OKB fields and Salesforce fields.
  6. For each iteration of the XML file, insert a row in the .csv with field values for all the columns
  7. For rich text area fields create an HTML file in the ‘data’ folder and mention the file path in the field value when you insert a record in the .csv
  8. In case HTML fields contain img tags, copy an image from the src link to the local folder ‘img’ created in step 2 and change the src path to the local ‘img’ folder in the HTML file.
  9. Example: Consider sample tag as <img src=’’ /> after the logic execution test.jpg is copied to the ‘img’ folder and image source is updated as <img src=’/data/img/test.jpg’ /> in the HTML. To test the same, launch the HTML file in the ‘data’ folder.
  10. Zip the files in Articles_Folder and import them into the salesforce

You got to know the detailed steps to export articles from the salesforce sandbox. I hope this information helps you in your lightning knowledge adventures and appreciate your feedback or queries in the comments section below. Happy to update the details in case anything is missed.

You may also like

Post a Comment


  1. Thanks Naveen. your explanation is awesome. but still i have a question which was not covered in your post. what if I have a document link in html file which will open a pdf file

  2. Thanks for the feedback.

    If there is a pdf document link in the html file, we have to migrate the file to the destination org, and map that file url in the HTML code before importing it.

    In another case... if the pdf file location servers and its link doesn't change, we can keep the same link in the HTML file. When you import the HTML file in the destination org, pdf link points to the same URL.