Skip to content

Instantly share code, notes, and snippets.

simpluslabs

Block or report user

Report or block simpluslabs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View AccountController.cls
/**
* Created by NigamGoyal on 3/11/2019.
*/
public with sharing class AccountController {
@AuraEnabled(cacheable=true)
public static List<Account> getAccountRecordWithRelatedContactList(Id recordId) {
List <Account> accountList = new List<Account>();
View createRecord.js-meta.xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>45.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>
View createRecord.js
import { LightningElement, track } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { createRecord } from 'lightning/uiRecordApi';
import { reduceErrors } from 'c/ldsUtils';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
import NAME_FIELD from '@salesforce/schema/Account.Name';
export default class LdsCreateRecord extends LightningElement {
@track accountId;
View createRecord.html
<template>
<lightning-card title="CreateRecord" icon-name="standard:record">
<div class="slds-m-around_medium">
<lightning-input label="Id" disabled value={accountId}></lightning-input>
<lightning-input label="Name" onchange={onNameChange} class="slds-m-bottom_x-small"></lightning-input>
<lightning-button label="Create Account" variant="brand" onclick={createAccount}></lightning-button>
</div>
</lightning-card>
View createAccountRecord.js-meta.xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>45.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>
View createAccountRecord.js
import { LightningElement } from 'lwc';
import accountObject from '@salesforce/schema/Account';
import nameField from '@salesforce/schema/Account.Name';
import websiteField from '@salesforce/schema/Account.Website';
import industryField from '@salesforce/schema/Account.Industry';
export default class CreateAccountRecord extends LightningElement {
// Code for create the Account Record
accountObject = accountObject;
View createAccountRecord.html
<template>
<lightning-card title="Create Account" icon-name="custom:custom57"></lightning-card>
<div class="slds-grid slds-wrap slds-p-around_small">
<!-- Create a record with Lightning Data Service -->
<div class="slds-col">
<lightning-record-form object-api-name={accountObject} fields={myFields} onsuccess={handleSuccess} onsubmit={handleSubmit}> mode="edit">
</lightning-record-form>
</div>
</div>
View fetchUpdateDeleteRecord.js-meta.xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>45.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>
View fetchUpdateDeleteRecord.js
import { LightningElement, wire, track, api } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { refreshApex } from '@salesforce/apex';
import { deleteRecord } from 'lightning/uiRecordApi';
import { updateRecord } from 'lightning/uiRecordApi';
import getAccountRecordWithRelatedContactList from '@salesforce/apex/AccountController.getAccountRecordWithRelatedContactList';
import contactObject from '@salesforce/schema/Contact';
import Id from '@salesforce/schema/Contact.Id';
import contactFirstName from '@salesforce/schema/Contact.FirstName';
import contactLastName from '@salesforce/schema/Contact.LastName';
View fetchUpdateDeleteRecord.html
<!--
- Created by NigamGoyal on 3/11/2019.
-->
<!-- fetchUpdateDeleteRecord -->
<template>
<lightning-card title="FetchUpdateDeleteRecord" icon-name="standard:record">
<div class="slds-m-around_medium">
<template for:each={accountList} for:item="accountObj">
<template for:each={accountObj.Contacts} for:item="relatedContactObj">
You can’t perform that action at this time.