Skip to content

Instantly share code, notes, and snippets.

public with sharing class ListViewController {
/**This is the list which will be passed to Visualforce Page and in turn passed to Flow from Visualforce**/
public List < Case > LstSelectedCases {
get;
set;
}
public ListViewController(ApexPages.StandardSetController listcontroller) {
<apex:page standardController="Case" recordSetVar="Cs" extensions="ListViewController" lightningStylesheets="True">
<!--This is how we call the Flow with a input paramater. Here CasesSelectedRecs is the input variable of the Flow-->
<flow:interview name="CaseListView">
<apex:param name="CasesSelectedRecs" value="{!LstSelectedCases}" />
</flow:interview>
</apex:page>
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>48.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>
import { LightningElement, wire } from "lwc";
import callNewsPoint from "@salesforce/apex/ArticleDataController.callNewsPoint";
export default class ShowNews extends LightningElement {
/**Getting Data from the Server Side Controller.Ideally do the error handling for the returend data using error attribute **/
@wire(callNewsPoint)
newsarticles;
}
.container {
max-width: fit-content;
background-color: gray;
}
.clip {
max-width: fit-content;
}
<template>
<template if:true={newsarticles.data}>
<div class="slds-size_3-of-4">
<div class="slds-box slds-box_x-small slds-text-align_center slds-m-around_x-large container">News Widget
<lightning-carousel scroll-duration="3" class="clip">
<template for:each={newsarticles.data} for:item="rec" for:index="index">
<lightning-carousel-image key={rec.title} src={rec.urlToImage} header={rec.title}
description={rec.description} alternative-text="First card accessible description."
href={rec.url}>
public without sharing class ArticleDataController {
@AuraEnabled(cacheable =true)
public static list<articles> callNewsPoint(){
/** Tip: Currently this query is all hardcoded. Use custom settings/labels to store parameters in actual implementations! **/
String endpoint ='https://newsapi.org/v2/top-headlines?country=in&category=business&apiKey=83521c49abfc4b698b98cd46918d78af';
HTTP h = new HTTP();
HTTPRequest req = new HTTPRequest();
req.setEndPoint(endpoint);