Popover Dialog using Aura Lightning Component
How to create Messaging End User using Apex in Salesforce?
How to add Knowledge widget in Salesforce Lightning Console?
1. In the Lightning Record Page, use the Knowledge component.
2. When you open a Case record, it will display the relevant Articles.
3. Attach Article can be use to attach the Article to the Case.
4. Once the Articles are attached, it will be available in Articles related list to the Case record.
How to create External object and relate it to Salesforce Object using Heroku?
1. Create a Heroku App.
2. Go to Resource Tab. Install Heroku Connect and Heroku Postgres add-ons.
3. Create a table in Heroku Postgres. Make sure to create a column to relate it to Salesforce object. In my example, I have used Account_Number column.Using FindOrCreate from Salesforce Chat to link Account to Chat Transcript
liveagent.addCustomDetail( "Company", "Disney" );
liveagent.addCustomDetail( "First Name", "Mickey" );
liveagent.addCustomDetail( "Last Name", "Mouse" );
liveagent.addCustomDetail( "Email", "[email protected]" );
liveagent.addCustomDetail( "Case Subject", "Test" );
liveagent.addCustomDetail( "Case Status", "New" );
/* FindOrCreate Account and linking to Chat Transcript */
liveagent.findOrCreate( "Account" ).map( "Name", "Company", true, true, true ).saveToTranscript( "AccountId" ).showOnCreate();
/*
This does a non-exact search on cases by the value of the "Case Subject" custom detail.
If no results are found, it will create a case and set the case's subject and status
The case that's found or created will be associated to the chat and the case will open in
the Console for the agent when the chat is accepted
*/
liveagent.findOrCreate( "Case" ).map( "Subject", "Case Subject", true, false, true ).map( "Status", "Case Status", false, false, true ).saveToTranscript( "CaseId" ).showOnCreate();
/*
This searches for a contact whose first name, last name ane email exactly match the values in the custom details for First Name, Last Name and Email.
If no results are found, it will create a new contact and set it's first name, last name, and Email to the values in the custom details
*/
liveagent.findOrCreate( "Contact" ).map( "FirstName", "First Name", true, true, true ).map( "LastName", "Last Name", true, true, true ).map( "Email", "Email", true, true, true );
/* The contact that's found or created will be saved or associated to the chat transcript.
The contact will be opened for the agent in the Console and the case is linked to the contact record */
liveagent.findOrCreate( "Contact" ).saveToTranscript( "ContactId" ).showOnCreate().linkToEntity( "Case", "ContactId" );
Using FindOrCreate from Salesforce Chat
liveagent.addCustomDetail( "First Name", "Mickey" );
liveagent.addCustomDetail( "Last Name", "Mouse" );
liveagent.addCustomDetail( "Email", "[email protected]" );
liveagent.addCustomDetail( "Case Subject", "Test" );
liveagent.addCustomDetail( "Case Status", "New" );
/*
This does a non-exact search on cases by the value of the "Case Subject" custom detail.
If no results are found, it will create a case and set the case's subject and status
The case that's found or created will be associated to the chat and the case will open in
the Console for the agent when the chat is accepted
*/
liveagent.findOrCreate( "Case" ).map( "Subject", "Case Subject", true, false, true ).map( "Status", "Case Status", false, false, true ).saveToTranscript( "CaseId" ).showOnCreate();
/*
This searches for a contact whose first name, last name ane email exactly match the values in the custom details for First Name, Last Name and Email.
If no results are found, it will create a new contact and set it's first name, last name, and Email to the values in the custom details
*/
liveagent.findOrCreate( "Contact" ).map( "FirstName", "First Name", true, true, true ).map( "LastName", "Last Name", true, true, true ).map( "Email", "Email", true, true, true );
/* The contact that's found or created will be saved or associated to the chat transcript.
The contact will be opened for the agent in the Console and the case is linked to the contact record */
liveagent.findOrCreate( "Contact" ).saveToTranscript( "ContactId" ).showOnCreate().linkToEntity( "Case", "ContactId" );
Agent Photo/Agent Avatar in Salesforce Embedded Service Chat
How to show Queue Position in Salesforce Chat?
<style>
body { overflow: hidden; width: 100%; height: 100%; padding: 0; margin: 0 }
#waitingMessage {
height: 50%;
width: 50%;
vertical-align: middle;
text-align: center;
display: none;
}
#liveAgentClientChat.liveAgentStateWaiting #waitingMessage { display: table; }
#liveAgentSaveButton, #liveAgentEndButton { z-index: 2; }
.liveAgentChatInput {
height: 25px;
border-width: 1px;
border-style: solid;
border-color: #000;
padding: 2px 0 2px 4px;
background: #fff;
display: block;
width: 99%;
}
.liveAgentSendButton {
display: block;
width: 60px;
height: 31px;
padding: 0 0 3px;
position: absolute;
top: 0;
right: -67px;
}
#liveAgentChatLog {
width: auto;
height: auto;
top: 0px;
position: absolute;
overflow-y: auto;
left: 0;
right: 0;
bottom: 0;
}
</style>
<div style="top: 0; left: 0; right: 0; bottom: 0; position: absolute;">
<liveAgent:clientChat >
<liveAgent:clientChatSaveButton />
<liveAgent:clientChatEndButton />
<div style="top: 25px; left: 5px; right: 5px; bottom: 5px; position: absolute; z-index:0;">
<liveAgent:clientChatAlertMessage />
<liveAgent:clientChatStatusMessage />
<table id="waitingMessage" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2">
Please wait while you are connected to an available agent.
</td>
</tr>
<tr>
<td>Your current Queue position is</td>
<td><liveAgent:clientChatQueuePosition /></td>
</tr>
</table>
<div style="top: 0; right: 0; bottom: 41px; left: 0; padding: 0; position: absolute;word-wrap: break-word; z-index: 0;">
<liveAgent:clientChatLog />
</div>
<div style="position: absolute; height: auto; right: 0; bottom: 0; left: 0; margin-right:67px;">
<liveagent:clientChatInput /><liveAgent:clientChatSendButton />
</div>
</div>
</liveAgent:clientChat>
</div>
</apex:page>
Heroku Architecture Designer Exam preparation
Videos:
Heroku Platform Basics for Partners - https://www.youtube.com/watch?v=PDTsT0e3evQ
https://www.youtube.com/watch?v=AKbxVwzP11c
Trailhead Resources:
https://trailhead.salesforce.com/en/users/equek/trailmixes/heroku-for-partners-beginner
https://trailhead.salesforce.com/content/learn/trails/heroku_enterprise
JavaScript Closure
Sample Code:
function simpleFunc() {
let strName = 'Magulan';
function showName() {
alert( strName);
}
return showName;
}
var myFunc = simpleFunc();
myFunc();//alerts Magulan which is outer function variable.
It shouldn't alert Magulan since the strName is a variable from outer function. It is alerting because of closures. A closure is the combination of a function and the lexical environment within which that function was declared. This environment consists of any local variables that were in-scope at the time the closure was created.
Another Sample Code:
function add( x ) {
return function( y ) {
return x + y;
};
}
let obj = add( 2 );
alert( obj( 3 ) );//alerts 5
How to create a table with date column and create records using PostgreSQL?
CREATE TABLE Claim (
Account_Number VARCHAR( 25 ) NOT NULL,
Claim_Amount INTEGER NOT NUll,
Claim_Id SERIAL PRIMARY KEY,
Claim_Date Date NOT NULL
);
To Create records:
INSERT INTO Claim ( Account_Number, Claim_Amount, Claim_Date ) VALUES
( 'Acc126', 1000, '2019-10-10' ),
( 'Acc126', 1300, '2011-02-21' ),
( 'Acc126', 1000, '2012-11-18' ),
( 'Acc126', 2000, '2019-07-15' ),
( 'Acc126', 8000, '2013-08-14' ),
( 'Acc126', 6040, '2016-06-11' ),
( 'Acc127', 1040, '2019-05-09' ),
( 'Acc127', 1000, '2014-04-30' ),
( 'Acc127', 5000, '2015-03-22' );
How to end Messaging Session from Salesforce Einstein Bot?
How to create/insert record(s) into Postgres Table using PostgreSQL?
Syntax:
INSERT INTO table_name ( column1_Name, column2_Name, ... ) VALUES ( column1, column2, ... );
Examples:
Inserting one record:
INSERT INTO interested_car ( interested_car_name ) VALUES ( 'Honda' );
Inserting multiple records:
INSERT INTO interested_car ( interested_car_name ) VALUES
( 'Kia' ),
( 'Toyota' ),
( 'Hyundai' );
How to create a table using PostgreSQL?
Syntax:
CREATE TABLE table_name (
column1 datatype(length) column_contraint,
column2 datatype(length) column_contraint,
column3 datatype(length) column_contraint,
table_constraints
);
Example:
CREATE TABLE interested_car (
id SERIAL PRIMARY KEY,
interested_car_name VARCHAR ( 50 ) NOT NULL
);
SERIAL - for auto increment
Messaging Sessions getting transferred to Agents from Einstein Bot in Salesforce
Error Handler Dialog can be used to avoid this issue. Using Error Handler Dialog, we can show user-friendly message to the customer. We can avoid transferring it to the agent also.
1. Create a simple Bot.
Custom CSS properties for lightning-tab in Salesforce Lightning Web Component
HTML:
<template>
<lightning-card>
<lightning-tabset>
<lightning-tab label="Item One">
First Content
</lightning-tab>
<lightning-tab label="Item Two">
Second Content
</lightning-tab>
<lightning-tab label="Item Three">
Thrird Content
</lightning-tab>
</lightning-tabset>
</lightning-card>
</template>
JavaScript:
import { LightningElement } from 'lwc';
export default class SampleLWC extends LightningElement {
}
CSS:
:host {
--sds-c-tabs-list-color-border: black;
--sds-c-tabs-item-color-border-active: red;
--sds-c-tabs-item-color-border-hover: green;
--sds-c-tabs-item-text-color: black;
--sds-c-tabs-item-text-color-active: green;
}
JS-meta.xml:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>51.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__Tab</target>
</targets>
</LightningComponentBundle>
Output:
Monitor Einstein Bot in Salesforce
CSS Updates to SLDS in Lightning Web Component Salesforce
HTML:
<template>
<lightning-card>
<lightning-button
variant="brand"
label="Submit">
</lightning-button>
</lightning-card>
</template>
JavaScript:
import { LightningElement } from 'lwc';
export default class SampleLWC extends LightningElement {
}
CSS:
:host {
--sds-c-button-brand-color-background: black;
--sds-c-button-brand-color-border: white;
--sds-c-button-brand-text-color: purple;
--sds-c-button-brand-text-color-hover: green;
}
js-meta.xml:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>51.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__Tab</target>
</targets>
</LightningComponentBundle>
Output:
System.UnexpectedException: Something went wrong getting your credentials in Salesforce
How to show parent record information using Related Record component in Salesforce Lightning?
Use Edit Layout button to add the fields to be added on the page.
Report on Salesforce Classic Users(Toggling between Lightning and Classic)
Simple Quick Action to Email Case Contact in Salesforce
2. Create a Quick Action.Make sure Contact Id is added to To Recipients and the Email Template is selected in "Default email Template".