Destructuring on objects lets you bind variables to different properties of an object. For ES6 ideally destructuring is consider as best practice rather than traversing object through dot notation.

Kiana Khansmith

if i look back, i am lost

祝日 / Permanent Vacation

tannertan36
occasionally subtle
Peter Solarz

Love Begins
Misplaced Lens Cap
tumblr dot com
he wasn't even looking at me and he found me

oozey mess
YOU ARE THE REASON

blake kathryn
we're not kids anymore.

@theartofmadeline
Today's Document
Jules of Nature
RMH

pixel skylines
Sweet Seals For You, Always
seen from Brazil
seen from Germany

seen from United States
seen from United States
seen from United States
seen from United States
seen from United States
seen from United States
seen from United States
seen from United States
seen from United States
seen from United States
seen from United States

seen from United States
seen from United States
seen from Netherlands
seen from United States
seen from United States

seen from India
seen from United States
@salesforceblog
Destructuring on objects lets you bind variables to different properties of an object. For ES6 ideally destructuring is consider as best practice rather than traversing object through dot notation.
Salesforce LWC datatable onHandleSort
onHandleSort(event) { this.sortedBy = event.detail.fieldName; this.sortDirection = event.detail.sortDirection; console.log('---'+this.sortedBy+'---'+this.sortDirection); let cloneData = [...this.data]; let orderSeq = this.sortDirection === 'asc' ? 1 : -1; let orderByField = this.sortedBy; cloneData.sort((a,b) => a[orderByField] > b[orderByField] ? (1*orderSeq) : (b[orderByField] > a[orderByField] ? (-1*orderSeq) : 0)); this.data = cloneData; console.log('---'+JSON.stringify(this.data)); }
Salesforce LWC Javascript sorting
let points = [10,9,15]; let names = ['Amulya','Prasanta']; let dates = [new Date('2020-09-01'),new Date('2020-10-01')];
let oderBy = 'desc'; let orderSeq = oderBy === 'asc' ? 1 : -1;
//Integer sorting points.sort((a,b) => a > b ? (1*orderSeq) : (b > a ? (-1*orderSeq) : 0)); console.log(points);
//String sorting names.sort((a,b) => a > b ? (1*orderSeq) : (b > a ? (-1*orderSeq) : 0)); console.log(names);
//String sorting dates.sort((a,b) => a > b ? (1*orderSeq) : (b > a ? (-1*orderSeq) : 0)); console.log(dates); ------------------------------ let employees = [{'Name':'Prasanta','Age':24},{'Name':'Amulya','Age':34}];
let orderByField = 'Age' let oderBy = 'desc'; let orderSeq = oderBy === 'asc' ? 1 : -1;
//Integer sorting employees.sort((a,b) => a[orderByField] > b[orderByField] ? (1*orderSeq) : (b[orderByField] > a[orderByField] ? (-1*orderSeq) : 0)); console.log(employees);
LWC Navigate to URL
navigateToUrl(){ this[NavigationMixin.GenerateUrl]({ type : 'standard_webPage', attributem : { url : '/apex/AccountVFExample?id='+this.recordId } }).then(generatedUrl => { window.open(generatedUrl); }); }
Java script / LWC to leverage forEach or Filter for iterating over list.
Opportunity Open/Closed check ?
Every Opportunity Stage Name results in either Open, Closed/Won, or Closed/Lost :
Open: IsClosed = FALSE, IsWon = FALSE
Closed/Lost: IsClosed = TRUE, IsWon = FALSE
Closed/Won: IsClosed = TRUE, IsWon = TRUE
Most commonly used string methods available for Salesforce Apex.
Different tools available for Salesforce development.
01. App Builder
02. Community Builder
03. Developer Console
04. Dataloader.io
05. Flow Builder
06. Process Builder
07. Salesforce Extensions for VS Code
08. Salesforce CLI
09. Schema Builder
10. Setup menu
11. Workbench
12. Code Builder
13. Data Loader
14. https://salesforcelwc.herokuapp.com
VS Code setup for Salesforce developer org or Sandbox
A complete demo how we can setup Salesforce developer orgs or sandbox orgs using VS Code.
Salesforce apex to generate fixed length unique key from any length input string.
To generate a fixed length external key from an input string may save your day to check uniqueness of a record or row. Here is how you can do it using apex.
Example 1 :
String s = 'I love Salesforce LWC'; Blob hash = Crypto.generateDigest('MD5', Blob.valueOf(s)); System.debug('---'+EncodingUtil.convertToHex(hash));
Output : d519b03aaa88e91bf85d23dd1e749f20
Example 2 :
String s = 'I love Salesforce'; Blob hash = Crypto.generateDigest('MD5', Blob.valueOf(s)); System.debug('---'+EncodingUtil.convertToHex(hash));
Output : b020bec285ff755a14fe1ebf825bfa07
ECMAScript 6 - ECMAScript 2015
let numVal = 10; console.log(Number.isInteger(numVal));//true console.log(Number.isSafeInteger(numVal));//true
numVal = 10.5; console.log(Number.isInteger(numVal));//false console.log(Number.isSafeInteger(numVal));//false
numVal = 9999999999999999; console.log(Number.isInteger(numVal));//true console.log(Number.isSafeInteger(numVal));//false
let strVal = 'Hello'; console.log(isNaN(numVal));//false
let powVal = Math.pow(5,2); //ES5 console.log(powVal);//25 powVal = 5**2; //ES5 console.log(powVal);//25
console.log(isFinite(10/0));//false console.log(isFinite(10/1));//true
Salesforce REST API Composite for parent child insert
End Point : https://instance.force.com/services/data/v48.0/composite
Method: POST
Request Body (Limits up to 25 records) :
{
"compositeRequest" :
[
{
"method" : "POST",
"url" : "/services/data/v38.0/sobjects/Account",
"referenceId" : "refAccount",
"body" : { "Name" : "Sample Account" }
},
{
"method" : "POST",
"url" : "/services/data/v38.0/sobjects/Contact",
"referenceId" : "refContact",
"body" : {
"LastName" : "Sample Contact",
"AccountId" : "@{refAccount.id}"
}
}
]
}
Reference Body
{
"compositeResponse": [
{
"body": {
"id": "0011C00002l5FyeQAE",
"success": true,
"errors": []
},
"httpHeaders": {
"Location": "/services/data/v38.0/sobjects/Account/0011C00002l5FyeQAE"
},
"httpStatusCode": 201,
"referenceId": "refAccount"
},
{
"body": {
"id": "0031C00003CtzOjQAJ",
"success": true,
"errors": []
},
"httpHeaders": {
"Location": "/services/data/v38.0/sobjects/Contact/0031C00003CtzOjQAJ"
},
"httpStatusCode": 201,
"referenceId": "refContact"
}
]
}
Salesforce composite REST API to Create Multiple Records with Fewer Round-Trips
Endpoint: https://instance.force.com/services/data/v48.0/composite/sobjects
Method: POST
Request------------------------------------------------------------------------------
{
"allOrNone" : false,
"records" : [
{
"attributes" : {"type" : "Contact"},
"lastName”: "Prasanta",
"email" : "[email protected]"
},
{
"attributes" : {"type" : "Contact"},
"lastName" : "pardhi",
"email" : "pardhi"
}
]
}
Response ------------------------------------------------------------------------------
[
{
"id": "0031C00003CtsQDQAZ",
"success": true,
"errors": []
},
{
"success": false,
"errors": [
{
"statusCode": "INVALID_EMAIL_ADDRESS",
"message": "Email: invalid email address: pardhi",
"fields": [
"Email"
]
}
]
}
]
In Salesforce Lightning Experience we can get the URL parameters inside a Lightning Web Component (LWC) by wiring a CurrentPageReference properties and accessing the state attribute.
We can backup Salesforce data into Amazon S3 bucket in a minute by leveraging Amazon AppFlow and without writing any code.
While building custom REST API for Salesforce or any other programming language, the most important thing we need to consider is to map proper HTTP method for a specific CRUD operation.
Salesforce LWC, to communicate between components on a single page, we can use the pubsub module. The pubsub service component need to be copied from here separately before implementing it in our LWC components.