Sunday, June 30, 2024

Apex Class

 

Class

public class AccountUtils {

    public static list<Account> accountsByState(String state){

        List<Account> listAcc=[select ID,name from Account where BillingState=:state];

        return listAcc;        

    }

}



Developer console

list<Account> lacc=new list<Account>();

lacc=AccountUtils.accountsByState('NC');

system.debug('**lacc'+lacc);

Sunday, June 23, 2024

Salesforce Development

 

Product Names



Install the Command Line Interface (CLI)

Salesforce CLI is the command-line tool for working with the Salesforce Platform. With Salesforce CLI, you can easily create environments for development and testing. Salesforce CLI also has commands to synchronize source code between your orgs and version control systems and to execute unit tests. 

See the Salesforce CLI Setup Guide for complete installation instructions for CLI.

  1. Install the Salesforce CLI.
  2. Confirm the CLI is properly installed and on the latest version by running the following command from the command line.
    sf update

Install Visual Studio Code and the Salesforce Extension Pack

Visual Studio Code is the Salesforce supported code editor for developers. The Salesforce extension pack contains features that leverage the Salesforce CLI to streamline development.

  1. Download and install the latest version of Visual Studio Code for your operating system. If you already have Visual Studio Code installed, there's no need to reinstall it.
  2. Launch Visual Studio Code.
  3. On the left toolbar, click Extensions.
  4. Search for Salesforce Extension Pack (Expanded) in the search field, click Salesforce Extension Pack (Expanded) and click Install.

Monday, June 17, 2024

Lightning Web Component

 Lightning Web Component


Data Binding:

    Ref Link: 

https://developer.salesforce.com/docs/platform/lwc/guide/js-props-getter.html

HTML:

<template>
<lightning-card title="Data binding">

<p class="slds-p-horizontal_small">
welcome to {message}
</p>
<lightning-input label="Name" value={message} onchange={handleChange}></lightning-input>
</lightning-card>
</template>

JS:

import { LightningElement } from 'lwc';

export default class DataBinding extends LightningElement {
message="Lightning Web Component";

handleChange(event){
this.message=event.target.value;
}

}
XML:

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>61.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__HomePage</target>
<target>lightning__RecordPage</target>

</targets>
</LightningComponentBundle>

Output

getterexample component:

HTML:
<template>
<lightning-card title="Getter Example">
<div class="slds-m-around_medium">
<lightning-input name="firstName" label="First Name" onchange={handleChange}
></lightning-input>
<lightning-input name="lastName" label="Last Name" onchange={handleChange}></lightning-input>
<p class="slds-m-top_medium">Uppercased Full Name: {uppercasedFullName}</p>
</div>
</lightning-card>
</template>


JS:
import { LightningElement } from 'lwc';

export default class GetterExample extends LightningElement {
firstName = " ";
lastName = " ";

handleChange(event) {
const field = event.target.name;
if (field === "firstName") {
this.firstName = event.target.value;
} else if (field === "lastName") {
this.lastName = event.target.value;
}
}

get uppercasedFullName() {
console.log("**FirstName "+this.firstName);
console.log("**LastNAme "+this.lastName);
return `${this.firstName} ${this.lastName}`.toUpperCase();
}
}

XML
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>61.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__HomePage</target>
<target>lightning__RecordPage</target>

</targets>
</LightningComponentBundle>

Output:


Communication using events

Events in LWC


  • Browser Events

  • Simple Event

  • Bubble Event

  • Composed Event

  • Pub Sub



https://github.com/trailheadapps


Dreamhouse App


https://trailhead.salesforce.com/content/learn/projects/quick-start-dreamhouse-sample-app

https://github.com/trailheadapps/dreamhouse-lwc

https://trailhead.salesforce.com/content/learn/projects/get-started-with-salesforce-development?trailmix_creator_id=sampatharjunan&trailmix_slug=dev-day-1-salesforce-overview