Saturday 5 September 2020

Install Visual Studio Code for Salesforce

Visual Studio code editor is the recommended code editor  to work with LWC . 

It has many plugins to support  development , testing and deployment. 

Click  here to get the latest version of Visual Studio Code . 

Launch the Visual studio code and click on the  Extensions. 

Search for Salesforce Extension Pack and install it.   

Now Press Ctrl + Shift + p , it will open place to search for command . 

Some times Visual Studio code unable to recognize  Salesforce CLI ,  Install Salesforce CLI from here  

Monday 31 August 2020

LWC Syntax Guide

  calling apex class :

1. Import apex method to use 

with name space-- 

import apexMethodName from '@salesforce/apex/Namespace.Classname.apexMethodReference';

without name space:

import apexMethodName from '@salesforce/apex/Classname.apexMethodReference';

2. invoke the method that was imported 

 we have three ways to invoke executed method 

2.1  wire a property 

2.2 wire a function 

2.3 call method imperatively

2.1 example   wire property 

@wire(apexMethod, { apexMethodParams }) propertyOrFunction; 

2.2 example wire function

 @track returnValues;

    @track error;

  @wire(apexMethod, { apexMethodParams })

    wiredFunction({ error, data }) {

        if (data) {

            this.returnValues = data;

            this.error = undefined;

        } else if (error) {

            this.error = error;

            this.returnValues = undefined;

        }

    }

2.3 calling apex imperatively

    @track returnValues;

    @track error;

    handleLoad() {

        apexMethod()

            .then(result => {

                this.returnValues = result;

            })

            .catch(error => {

                this.error = error;

            });

    }

Simplest way to solve VS code Newtwork issue

Problem :  vs code not owrking in office client network , becuase of proxy
Soltuions : we have doffrent soltions like setting host and proxy variables,  if we do so, it won't work in other networks . I am happy to share other new way of solving issue with minimal steps . 
Step1. Control + shift +P , then search for terminal: change default shell , default it will be power shell ,  sellect cmd as default shell .
Step2. Click on new terminal, now it will open cmd terminal , close terminal 1 which is PS(power shell ) . 
Now your vs code will work with any newtwork if can access them in bwowser . 

Monday 22 June 2020

Why LWC

When we have web standards with latest HTML, why we need Lightning web components ?   

lwc is there to fill the gaps of web standards . 

Advantages of LWC :
More Standards , less proprietary
Common component model
Transferable skills
Easier- to- Ramp-up for developers 
Better performance

Business Hours for Assigning and re-Assigning

In every industry  auto assignment and re-assignment of  owners , will save lot of time for management .
In this process business hours will plays an important role. Now we will see how to calculate business hours .  
Use case 1: When lead is created the lead should assigned to particular agent, if the agent is not taken any action  with in the defined business hours (8hours) then the lead should assigned to an other sales agent . 

1. while creating lead we need to assign lead to sales agent .
2. While creating lead we will store the business hours in separate object  named CustomAssignments along with leadlookup and userlookup . if  we dont want user as lookup we can make user of owner of CustomAssignments .  
3.future dependent action on   CustomAssignments  for reassignment. 

 considerations :  standard assignment rules not considered because of complex assigenemtn and reassignment process . 
Created separate object  to store due-date/ re-assignment date with lookup of lead/other objects and lookup of user.  This helps in handling  future depend actions . 

use the following method  to get the business hours  while creating custom object . 
Business hours class : 

public class utility {
Public static BusinessHours bHours; 
public static datetime getBusinessHour(){
    if(bHours==null){
       bHours = [SELECT Id FROM BusinessHours WHERE IsDefault=true];  // name of your business hours   
    }
   return  BusinessHours.add(bHours.Id, Datetime.Now (), 32400000);// time in milli seconds 
      
    }

}

Saturday 13 June 2020

Importance of web browser In the Industry

In previous days before 2014. Industries are dependent on legacy applications. We can see how the customers are accessing the services in the bellow image.  

Later people showed more interest on browser to access services   instead of  native  apps  (locally installed ). Now we can see how customers are accessing the services in the bellow image. 


at this time to over come challenges of the standard web browser there were plenty  of    libraries  are developed by different vendors like angular js ,  Aura components  etc.   Form then companies given  the importance to web standards so that it be unique . Facebook , google , Salesforce stated collaborating  to to W3 schools to make it  more efficient .  after 5 years in 2019 the web standards became more power full and capable of handling mange of the challenges of 2014 web stands . 
we can have a comparison in bellow image .









Thursday 6 February 2020

Difference between component event and Aura method

In simple line aura:methods will be more faster than component event , since it don't required one more communication layer in the form of event. So always use aura:method when ever it is possible .
Here we have taken a example. We have parent component  and child component . both have the aura:attribute vehicles.   We can pass vehicles to child component at the time of Initialization, with out any event . In child component vehicle attribute will get data from parent , doint method will count the sum and assign the value to child attribute count. let us assume that it has 10.
Now in child component we have given possibility to add vehicle. Now in child component java script we have added new vehicle to vehicle attribute and count to count attribute  . At this stage we will have 11 vehicles in vehicle child attribute , count as 11 in child count attribute.  Since the added information was not     communicated back to  parent , parent will have only 10 vehicles in parent vehicle attribute.  To fill this gap we use component events.  Now After component event communication we will have 11 vehicles in both child and parent. Now in parent component we added one more vehicle ,  This time it will automatically communicated with child since we have bind variable at the time of initialization .  Now child will have 12 vehicles in vehicle object but count as 11. At this time component will not initialize again, so do int count will not work. We have option to communicate with  variables, but we don't have option to perform calculations. To fill this gap , we have aura:method in child . when we are adding vehicle from parent    we will execute child component JavaScript method to perform calculations. This is the use of aura:method