Skip to content

Instantly share code, notes, and snippets.

@arun12209
arun12209 / ContentDocumentLink_TriggerHelper
Created Apr 25, 2020
ContentDocumentLink_TriggerHelper
View ContentDocumentLink_TriggerHelper
@arun12209
arun12209 / ContentDocumentLink_Trigger
Last active May 30, 2020
ContentDocumentLink_Trigger
View ContentDocumentLink_Trigger
View NEWSAPI_Callout
string baseURL='https://newsapi.org/v2/top-headlines';
String apiKey =''; //API key get it from Newsapi.org
HttpRequest reqest = new HttpRequest();
system.debug('EndPoint: '+baseURL+'?sources=national-geographic&apiKey='+apiKey);
reqest.setEndpoint(baseURL+'?sources=national-geographic&apiKey='+apiKey);
reqest.setMethod('GET');
reqest.setHeader('Accept','application/json');
Http h = new Http();
HTTPResponse response = h.send(reqest);
System.debug('result : + response.getBody());
View NewsApp
<apex:page showHeader="false" sidebar="false">
<apex:includeLightning />
<div id="LightningCompDisplayId"></div>
<script>
//please note that you need to create a lightning application and need to put the main component uder this app.
/* <aura:application access="GLOBAL" extends="ltng:outApp" implements="ltng:allowGuestAccess">
<aura:dependency resource="c:News"/>
<c:News />
@arun12209
arun12209 / COVID19_IND_LtngApp
Last active Apr 5, 2020
COVID19_IND_LtngApp
View COVID19_IND_LtngApp
<aura:application access="GLOBAL" extends="ltng:outApp" implements="ltng:allowGuestAccess">
<aura:dependency resource="c:Covid19_IND_Tracker"/>
<c:Covid19_IND_Tracker />
</aura:application>
View Covid19_Tracker_App
<apex:page showHeader="false" sidebar="false">
<apex:includeLightning />
<div id="LcDisplayId"></div>
<script>
$Lightning.use("c:Covid19_IND_TrackerApp", function() {
$Lightning.createComponent("c:Covid19_IND_Tracker",
@arun12209
arun12209 / Covid19_Tracking_ChartHelper
Created Apr 5, 2020
Covid19_Tracking_ChartHelper
View Covid19_Tracking_ChartHelper
({
CreateChart : function(component) {
var chartType= 'bar';
var action=component.get("c.fecthCovid19Data");
action.setCallback(this,function(response){
var state=response.getState();
if(state=='SUCCESS'){
var result = JSON.parse(JSON.stringify(response.getReturnValue()));
console.log('result : ' +JSON.stringify( result));
var data = [];
@arun12209
arun12209 / Covid19_Tracking_ChartController
Created Apr 5, 2020
Covid19_Tracking_ChartController
View Covid19_Tracking_ChartController
({
doInit : function(component, event, helper) {
helper.CreateChart(component);
}
})
View Covid19_Tracking_ChartCmp
<aura:component controller="Covid19_IND_TrackerController" access="global">
<!-- load chart js library from static resource-->
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<ltng:require scripts="/resource/Chart_Js/Chart.js-2.9.3/dist/Chart.bundle.js" />
<aura:attribute name="chartObj" type="object" access="public"/>
<aura:attribute name="property1" type="string"/>
<aura:attribute name="property2" type="string"/>
<div aura:id="chartContainer" style=" ">
<canvas aura:id="myChart" id="{!v.property1}" /><!--reportChart-->
View Covid19_NewsHelper
({
fetchNewsData : function(component, event, helper) {
var action=component.get("c.fetchNews");
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var result = JSON.parse(JSON.stringify(response.getReturnValue()));
component.set('v.newsData',result.articles);
console.log('Articles = '+JSON.stringify(result.articles));
//console.log(' Result : ' +JSON.stringify(result.articles[0].title));