Skip to main content

Covid Status Tracker Single page Application using Salesforce Force.com Sites

Step1:
Create Corona Cases Object with the below fields.
State__c,
State_Code__c,
Confirmed__c,
Active__c,
Recovered__c,
Deaths__c,
Today_New_Cases__c,
Today_Recovered__c,
Today_Deaths__c,
Last_Updated_Time__c

Step2:
Register the Open Source API site under Remote Site Settings















Step3:
Create a Callout class in Salesforce using REST API to call the Opensource API from https://api.covid19india.org/data.json

Callout Class:
https://github.com/NagarjunaKaipu/myLightning/blob/master/CovidInfoCallOuts.apxc
JSON2APEX Class.
https://github.com/NagarjunaKaipu/myLightning/blob/master/CovidJson.apxc
Sample JSON from Third-party Application.
https://github.com/NagarjunaKaipu/myLightning/blob/master/ThirdpartyRESTAPIJson.json

Step4:
Create a Schedulable class to run the callout class in the frequent intervals.
https://github.com/NagarjunaKaipu/myLightning/blob/master/ScheduleRefreshCovid.apxc

Step5:
Create Visualforce page to show the List of records on UI.

VF page:
https://github.com/NagarjunaKaipu/myLightning/blob/master/CovidStatus.vfp
Controller class:
https://github.com/NagarjunaKaipu/myLightning/blob/master/CovidStatusController.apxc

Step6:
Go to Sites and Configure the site as shown below 
Site Home Page as your Visulaforce  page
Go to Public Access Settings and give access to 
Corona Cases object
Visualforce page
Controller class













Step7:
Activate the Site and your site URL looks like below
https://covid19india-developer-edition.ap4.force.com/CovidStatus

Sample Output:





Comments

Popular posts from this blog

Get started with Simple Lightning Web Component(Bike Card)

Lightning web component HTML files all include the template tag. The template tag contains the HTML that defines the structure of your component. Let’s look at the HTML for a simplified version of the component. Paste the following into app.html (replacing any existing HTML in the file). bikeCard.html < template > < div id = "waiting" if : false = { ready } > Loading.. </ div > < div id = "dispaly" if : true = { ready } > < div > Name: {name} </ div > < div > Description: {description} </ div > < div > Category: {category} </ div > < div > Material: {material} </ div > < div > Price: {price} </ div > < div >< img src = { pictureURL } /></ div > </ div > </ template > The identifiers in the curly braces {} are bound to the fields of the same name in the corresponding JavaScript class. Here’s a JavaScript file to s...

Disable Document Download in Salesforce

Disable downloads for certain users based on the name of the file uploaded to Salesforce. We can use the following example code inside of a Apex class. This code essentially prevents files whose file name starts off with Kaipu- from being downloaded by anyone whose user role’s developer name is not Kaipu_Sales. Modify this code to suit your own purpose. Based on Role: public class ContentDownloadHandlerFactoryImpl implements Sfc.ContentDownloadHandlerFactory {    public Sfc.ContentDownloadHandler getContentDownloadHandler(List<ID> ids, Sfc.ContentDownloadContext context) {      // See if the user has the Kaipu Sales role (based on developer name field).      Boolean isSecretUser = [        SELECT Id        FROM UserRole        WHERE ID = :UserInfo.getUserRoleId()          AND DeveloperName = ' Kaip...

Salesforce Lightning Web Components Overview

What are Lightning Web Components(LWC)? Lightning web components are custom HTML elements built using HTML and modern JavaScript.  Now you can build Lightning components using two programming models: Lightning Web Components, and the original model, Aura Components.   Why we need to go for LWC? 1. It uses Core Web Components standards 2. Most of the code you write is standard JavaScript and HTML 3. Provides only what’s necessary to perform 4. It is built on code that runs natively in browsers 5. It is lightweight and delivers exceptional performance   Where can we implement LWC Components? Salesforce Developer Console won’t support LWC components. We need to install Visual Studio Code(VS Code) Editor to implement the LWC Components. LWC Component Bundle Structure: LWC Majorly contains 3 files HTML JavaScript Meta XML Naming Convention/Rules for Components Bundles 1.Component name Must begin with a lowercase letter 2.Name ...