Custom Knowledge Base setup in Salesforce Lightning (Add/Edit Article Lightning Components)

Client

Client is a US based Technology Consulting company. They provide affordable web development services/Cloud Services and strategic technical consulting for lean start-ups and enterprises.

Challenges

  1. The requirement was to make a Lightning Component which will insert new records in a custom object. Users of a selected Profile should be able to specify a record type, all other Users should only be allowed to submit with default record type.

    • This Lightning Component should also allow Users to:
    • Submit any number of attachments which get uploaded at the same time.
    • Submit any number of URLs as attachments.

    The categorizations of the object are stored in another custom object. This categorization was a bit complex as it was stored in a third custom object which was related to the records of the first custom object. This categorization was to be shown in a grouped manner with associated checkbox fields in the form.

  2. Client also wanted us to make a lightning component to edit the article. This page had to show article fields in editable mode and also had to show all attachments records related to this article, users can delete attachment and upload new file.

Solution

As per our analysis of the given requirements, We developed separate Lightning Components for each Add Article and Edit Article.

We developed add article lightning component with all necessary fields, including multiple file attachment and checkbox for category. The main challenge was to upload the multiple documents file at the same time.

As we all know the maximum heap size is 6MB, when we were trying to upload larger files we continuously failed to upload the files. Finally we decided to upload files in chunks for that We defined chunks size 950 000.In this way we read the file and converted file content in base64,We breaked the file size in chunks and uploaded files in standard document object, Upload method of javascript runs recursively until all chunks uploaded. Lightning component that we developed shown in the screenshot below.

Tim Project Image1

We developed edit article lightning component, we were showing all necessary fields in edit mode, we also included all attachment related to article on this edit page. From this page user can add new attachment and also can delete attachment in bulk.

Tim Project Image2

Result

  • Sales Manager can add article and can publish the article, other users can add article but he/she can not publish the article.
  • User can upload multiple attachments at the same time and can also insert multiple URL attachments. User can upload the maximum file size upto 4.3 MB.
  • User can edit the article record from edit article lightning component, and can also add and delete the related attachments.