To Achieve this, we need to create a Lightning Flow.
Let's go to practical.
Important : Before Creating a Flow, we need to create a Lightning Web Component.
Step 1 : fetchRecordsFromFlow.Html
<template>
<lightning-card>
<!--Lightning Datatable Start-->
<lightning-datatable data={records}
columns={fieldColumns}
key-field="id"></lightning-datatable>
</lightning-card>
<!--Lightning Datatable End-->
</template>
Step 2 : fetchRecordsFromFlow.Js
import { api, LightningElement } from 'lwc';
export default class FetchRecordsFromFlow extends LightningElement {
@api records = [];
@api fieldColumns = [
{ label: 'FirstName', fieldName: 'FirstName' },
{ label: 'LastName', fieldName: 'LastName'},
{ label: 'Email', fieldName: 'Email' }
];
}
Step 3 : fetchRecordsFromFlow.xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>52.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__FlowScreen</target>
</targets>
<targetConfigs>
<targetConfig targets='lightning__FlowScreen'>
<propertyType name='PT' extends='SObject' label='Select a sObject' description='Select a sObject'/>
<property name='records' type='{PT[]}' label='Records' description='Select Record List Variable'/>
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
Step 4 : How to Create Lightning Flow In Salesforce.
Follow Below Steps
1.) Search Flow in Quick Find Box 2.) Select Flows 3.) Click New Flow
4.) Select Screen Flow
5.) Click Next.
6.) Select Freeform And Now you have reached on flow screen.
7.) Here Drag and Drop Get Records Element on Canvas and give label and Select Object In Get Records of This Object Section. In this Example We are fetching records of Contact based on AccountId and Filter In Filter Contact Records Section.
In Field, Select AccountId Operators Equal And Value {1.}
1.) For Value Select New Resource => Resource Type Variable => ApiName recordId => Data Type Text => And Check Available For Input Checkbox And Done.
Now your Screen Should be look like this.
0 Comments
If you have any doubts please comment us