Thursday, 4 June 2020

                                          LWC Components     

  • lightning-record-form component allows you to quickly create forms to add, view, or update a record.
  • lightning-record-form implements Lightning Data Service and doesn’t require additional Apex controllers to create or edit record data. It also takes care of field-level security and sharing for you, so users see only the data that they have access to.
  • The object-api-name attribute is always required, and the record-id is required only when you’re editing or viewing a record.


·       The component accepts a mode value that determines the user interaction allowed for the form. The value for mode can be one of the following:
  • edit – Creates an editable form to add a record or update an existing one. When updating an existing record, specify the record-id. Edit mode is the default when record-id is not provided, and displays a form to create new records.
  • view – Creates a form to display a record that the user can also edit. The record fields each have an edit button. View mode is the default when record-id is provided.
  • readonly – Creates a form to display a record without enabling edits. The form doesn’t display any buttons.
·       This component doesn’t support all Salesforce standard objects. For example, the Event and Task objects are not supported.
·       External objects and person accounts are not supported.

    <lightning-card title="Record Form ReadOnly" icon-name="standard:account">
        <lightning-record-form record-id={recordId} object-api-name={objectApiName} fields={fields} columns="2" mode="readonly" onsubmit={handleSubmit}></lightning-record-form>
    <!-- Record Edit-->
    <lightning-card title="Record Form Edit" icon-name="standard:account">
        <lightning-record-form record-id={recordId} object-api-name={objectApiName} fields={fields} columns="2" mode="Edit" onsubmit={handleSubmit}></lightning-record-form>
    <!-- Record View-->
    <lightning-card title="Record Form View" icon-name="standard:account">
        <lightning-record-form record-id={recordId} object-api-name={objectApiName} fields={fields} columns="2" mode="View" onsubmit={handleSubmit}></lightning-record-form>
    <!-- Edit form -->
    <lightning-card title="Edit Form" icon-name="standard:account">
        <lightning-record-edit-form object-api-name={objectApiName}>
            <lightning-input-field field-name="Name" required></lightning-input-field>
            <lightning-input-field field-name="AnnualRevenue" required></lightning-input-field>
            <lightning-button type="submit" name="submit" label="Create Account" ></lightning-button>
    <!-- View Form-->
    <lightning-card title="View Form" icon-name="standard:account">
        <lightning-record-view-form record-id={recordId} object-api-name={objectApiName}>
            <lightning-output-field field-name="Name"></lightning-output-field>
            <lightning-output-field field-name="AnnualRevenue"></lightning-output-field>

import { LightningElement,api from 'lwc';
import Name_Field from '@salesforce/schema/Account.Name';
import Revenue_Field from '@salesforce/schema/Account.AnnualRevenue';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class RecordForm extends LightningElement {
    @api recordId;
    @api objectApiName;
    validateFields() {
        this.template.querySelectorAll('lightning-input-field').forEach(element => {


<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="">


<lightning-card title="PractiseWrapper"  icon-name="custom:custom63">
<div class="slds-m-arround_medium">
    <!-- check data present-->
    <template if:true={}>
        <template for:each={} for:item=wraper>
            <p key={wraper.accountId}> {wraper.accountName}</p>


import { LightningElement, wire } from 'lwc';
import getWrapperClassList from '@salesforce/apex/LWCLearning_wrapperController.getWrapperClassList'
export default class WraperClass extends LightningElement {

public with sharing class LWCLearning_wrapperController {
    public static List<wrapperClass> getWrapperClassList() {
        List<wrapperClasswrapperList = new List<wrapperClass>();
        for(Account acc: [select id, name from Account limit 5]){
            wrapperClass wc = new wrapperClass();
            wc.accountName =;
            wc.accountId = acc.Id;
        return wrapperList;
    public class wrapperClass{
        @AuraEnabled public String accountName;
        @AuraEnabled public String accountId;

Saturday, 8 February 2020

How to Query Multiple Child Objects in Single Query

Test 3 is Parent,Test1 and Test 2 have Lookup relation to Test 3

[select id,name,(select id,name from test1s__r),(select id,name from test2s__r) from test3__c]
 Standard Object As Example:
SELECT id,(SELECT Id,Status,CaseNumber FROM Cases),(SELECT Id,Name FROM Contacts) FROM Account