Posts

Showing posts from August, 2019

Lightning Spinner : Toast for LWC and Aura

Image
Lightning Spinner : Aura Component Aura Component : HTML Aura Component : CSS .THIS.spinner{ position: relative; display: inline-block; width: 51px; vertical-align: middle; white-space: nowrap; } Lightning Spinner : Lightning Web Component LWC : Template (HTML) Lightning Web Component : JS import { LightningElement, track } from 'lwc'; export default class Spinner extends LightningElement { @track loading = true; } Lightning Web Component : CSS .spinner{ position: relative; display: inline-block; width: 51px; vertical-align: middle; white-space: nowrap; } Note : You can hide spinner from JS via set loading=false attribute in both framework. Lightning Toast: Aura Component Just needed Call Standard Event to show : $A.get("e.force:showToast"); Aura Component : HTML Aura Comp

Lightning Datatable for LWC and Aura

Image
Lightning DataTable : Aura Component LightningDataTableController(Apex Controller ) public class LightningDataTableController{ @AuraEnabled public static List<Contact> fetchAccountContacts(String accountId) { List<Contact> lstContact=new List<Contact>(); lstContact=[select id ,Name,Email,Phone from contact where accountid=:accountId]; return lstContact; } } LightningDataTable.cmp (Component) <aura:component controller="LightningDataTableController" implements="force:hasRecordId,flexipage:availableForAllPageTypes,force:lightningQuickActionWithoutHeader" access="global"> <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> <aura:attribute name="data" type="Object"/> <aura:attribute name="columns" type="List" default="[{label: 'Name', fieldName: &#

Lightning Web Component and Lightning-Aura Component : Salesforce

Image
Lightning Web Component and Lightning-Aura Component : Salesforce Code Cheat Sheet for both Framework with Comparison 1. Component Bundles Lightning-Aura Component .comp : Markup or HTML Controller.Js : Client Side Controller Helper.Js : Client Side Util or Helper Controller Render.Js : Client Side Render Controller .css : CSS Resource for HTML .auradoc : Aura Documentation .design : Design Parameter for Builder .SVG : SVG Resource for Component Lightning Web Component .html : Markup or HTML Controller.Js : Client Side Controller .css : CSS Resource for HTML meta.xml : Design Parameter for Builder 2. JavaScript properties or Variables Lightning-Aura Component Lightning Web Component import { LightningElement, api, track } from 'lwc'; export default class fetchRecords extends LightningElement { @api recordId; @track sobject; } 3. Logical Operators Lightning-Aura Component //isLoading is a boolean variable in JS 3. Iterat

Calling Apex method from a Custom Button and Submit to Approval Process

Image
To call Apex method from a Custom Button and Submit to Approval Process : Salesforce 1. Create a custom button {!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")} var approval = confirm("Are you sure want to send it for approval process?"); if(approval == true) { sforce.apex.execute("ApprovalSubmit","sentToApproval",{recordId:"{!Interviewer__c.Id}"}); alert("Set Record for Approval"); } 2. Create a apex class : global class ApprovalSubmit{ webservice static void sentToApproval(Id recordId) { Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest(); req1.setComments('Submitted for Approval'); req1.setObjectId(recordId); Approval.ProcessResult res = Approval.Process(req1); } } Happy Sharing... Everyone has their own favourites, so p