Home Salesforce COVID India Real Data In Lightning Community

COVID India Real Data In Lightning Community

by Dhanik Lal Sahni

Coronavirus disease (COVID-19) is an infectious disease caused by a newly discovered coronavirus.  World is danger due to this pandemic. More then 7 Million public is positive with this virus.

This post will help in creating Lightning Community to show real time data of COVID virus patients in India.  To show real time data we need below steps

  1. API which will give real time data
  2. Consume above API in Salesforce
  3. Public Lightning Community
  4. Lightning Component to show data

1. Real time data API

Real time data for COVID patients is available at https://api.covid19india.org/. You can also get information about patients at https://github.com/covid19india

2. Consume API in Apex

We have to consume APIs from above mentioned site to get real time data of patients. We have consumed two APIs from this site.  First will get data of all states and second will get data of each district of state.

  1. https://api.covid19india.org/data.json
  2. https://api.covid19india.org/state_district_wise.json

3. Create Lightning Community

Above two steps will give data in required format. Now we have to create Lightning community to share this information to everyone.  I have used ‘Build Your Own’ theme to create lightning community.  To make community public we have to enable ‘Public can access the community’ setting in community builder.

4. Create Lightning Web Component to Show Data

Let us create lightning web component which will show data using above created COVIDDataService class. We have used lightning-card, lightning-combobox, lightning-datatable to show data in Lightning web component. This component is dragged on Lightning Community Page which is crated in step 3.

lightning-datatable is used to show state and district wise data.

<lightning-datatable key-field="state" data={nationaldata} show-row-number-column                                    columns={columns}>

Complete Lightning Web Component Code

Community Portal Linkhttps://vagminecodexone-developer-edition.ap15.force.com/covidindia/s/

You may also like

1 comment

Kishan March 30, 2020 - 3:30 pm

its a great integration and very needful for current situation .

Reply

Leave a Comment