Navigating to a Page in Lightning Community using Custom Lightning Component

Create a Standard Page with the name "Sample":

Add caption

Sample Code:

Component1 cmp:

  1. <aura:component implements="forceCommunity:availableForAllPageTypes" access="global" >  
  3.     <aura:attribute name="Txt" type="String" default=""/>  
  5.     <div class="slds-box slds-theme_default">  
  7.         This is component 1.<br/><br/>  
  8.         <lightning:input type="text" value="{!v.Txt}" label="Enter some text"/><br/>  
  9.         <lightning:navigation aura:id="navService"/>  
  10.         <lightning:button label="Navigate" onclick="{!c.navigateToComTwo}"/>  
  12.     </div>  
  14. </aura:component> 

Component1 JavaScript Controller:
  1. ({  
  3.     navigateToComTwo : function(component, event, helper) {  
  5.         event.preventDefault();  
  6.         var navService = component.find( "navService" );  
  7.         var pageReference = {  
  8.             type: "comm__namedPage",  
  9.             attributes: {  
  10.                 pageName: "sample"  
  11.             },  
  12.             state: {  
  13.                 sampleVar: component.get( "v.Txt" )  
  14.             }  
  15.         };  
  16.         sessionStorage.setItem('pageTransfer', JSON.stringify(pageReference.state));  
  17.         navService.navigate(pageReference);  
  19.     }  
  21. }) 

Component2 cmp:

  1. <aura:component implements="forceCommunity:availableForAllPageTypes" access="global" >  
  3.     <aura:attribute name="Text" type="String" default=""/>  
  5.     <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>  
  7.     <div class="slds-box slds-theme_default">  
  9.         This is component two.<br/><br/>  
  10.         Text is {!v.Text}.<br/><br/>  
  12.     </div>  
  14. </aura:component> 

Component3 JavaScript Controller:

  1. ({  
  3.     doInit : function( component, event, helper ) {  
  5.         var resultMsg = sessionStorage.getItem( 'pageTransfer' );  
  6.         component.set( "v.Text", JSON.parse( resultMsg ).sampleVar );  
  8.     }  
  10. }) 


CORS (Cross-origin resource sharing) in Salesforce

Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources on a web page to be requested from another domain outside the domain from which the first resource was served.

To allow client applications running in a web browser to access Salesforce information, you need to register the origin first. On your Salesforce ORG, go to Setup -> Security -> CORS. Include all the domains that need to access Salesforce resources through a web browser.

Salesforce will return the origin in the "Access-Control-Allow-Origin HTTP" header, along with any additional CORS HTTP headers, hence the browser will allow the request.

These Salesforce technologies support CORS.
Analytics REST API
Bulk API
Chatter REST API
Salesforce IoT REST API
Lightning Out
User Interface API

Salesforce Interview Questions with Answers Part 61

1. Classic vs Lightning Knowledge in Salesforce
Classic Knowledge
Article Types are used for showing differnt buttons and fields.

Lightning Knowledge
Looks similar to regular objects.
Record Types are used for showing differnt buttons and fields.
Agent Search tab helps to search articles. Filters are available in the left pane.

2. Lightning Knowledge in Salesforce
Looks similar to regular objects.

Record Types are used for showing different buttons and fields.

Agent Search tab helps to search articles. Filters are available in the left pane.

Article Category is for visibility requirements.

Approval works only for Draft articles.

3.Einstein Search in Salesforce
Search results are personalized based on record ownership, recent activity, geography, etc.

It allows us to hover. When we hover the suggestion, it will show additional information. Shows Page-level record actions, related list quick links and list views.

If you search "my open opportunities", it will show all your owned opportunities in open Stages(Negotiation, Discovery, Qualification, etc).
If you search "open opportunities", it will show all the opportunities in open Stages(Negotiation, Discovery, Qualification, etc) you have access to.
If you search "my open opportunities in Miami", it will show all your owned opportunities in open Stages(Negotiation, Discovery, Qualification, etc) where city is Miami.

We can use my, all, my team, my account team, my sales teams, colleague's name, etc during search.

If you search "acme contacts", it will show all the contacts which belongs to Acme Account. If there are multiple Acme accounts, you can click Looking for different acme? and select a different account.

Supports different search layouts for every profile for every object.

4. When calling apex GlobalDescribe on a standard object fails?
Calling apex GlobalDescribe on a standard object fails for standard objects added to the API in versions after the version of your apex class.

5.What Is A Gack?
If you’ve been around Salesforce long enough, you have probably encountered a screen saying "An internal server error has occurred."
That screen is what we call a GACK.
This message is part of an elaborate system for efficiently bringing these events to the attention of R&D.

On gack notification, you will see two numbers.
The first of these numbers has a hyphen in it, and the second number is in parentheses.
These two numbers are the identifying ID for that specific event, and the general stack trace that was produced by that failure.

6. What Is Apex Replay Debugger?
Apex Replay Debugger is a free tool that allows you to debug your Apex code by inspecting debug logs using Visual Studio Code as the client. Running the replay debugger gives you the same features you expect from other debuggers.

7. What Is Apex Interactive Debugger?
Apex Interactive Debugger, also included in the Salesforce Extension Pack, allows customers to debug their Apex code on sandboxes and scratch orgs, in real time, using Visual Studio Code as the client.

Apex Interactive Debugger also comes with features for independent software vendor (ISV) partners working with subscribers who install a managed package. Because of the protections against seeing managed code, subscribers can’t debug ISV code in their orgs. With ISV Customer Debugger, an ISV can work with a subscriber to debug issues specific to the subscriber’s org.

8. What are continuous integration, continuous delivery, and continuous deployment?
Continuous Integration
Using continuous integration, a product is built to include and integrate every code change on every commit (continuously), by any and all developers. An automated build then verifies each check-in, letting teams detect problems early.
Continuous integration (CI) is a component of the continuous delivery process that enables developers to integrate their updates into the master branch on a regular basis.
With CI, automated tests run before and after each change is merged, validating that no bugs have been introduced.

Continuous Delivery
Continuous delivery ensures that code can be rapidly and safely deployed to production by manually pushing every change to a production-like environment. Since every change is automatically delivered to a staging environment, you can deploy the application to production with a push of a button when the time is right.
The additional step of pushing the code to a staging environment is what makes continuous integration different than continuous delivery. Having a green (successful) build with CI doesn't mean your code is production ready until you push it to a staging environment that matches the final production environment.

Continuous Deployment
Continuous deployment is the next step of continuous delivery. Using Continuous Deployment, every change that passes the automated tests is deployed to production automatically.

9. var and let difference in JavaScript
var is a function-scoped. It can be re-declared.
let is a block-scoped. It can be used in for loops, while loops, if blocks. It cannot be re-declared.

Best Practice:
Do not use var in for/while loop, because after the loop, it will hold the value due to it’s availability.
var can be considered to be defined a global variable in the function scope. 

10.  Modular programming
Modular programming involves breaking your code up into logical chunks so that it’s easier to access. Using modules generally results in code that is easier to read and maintain.

11. Heroku Connect
 Heroku Connect provides both data replication and data proxies for Salesforce. Data replication synchronizes data between Salesforce and a Heroku Postgres database. Depending on how it's configured, the synchronization is either one way or bidirectional.
One of the biggest benefits of using Heroku Connect for data replication is that a subset of Salesforce data is quickly and easily accessible to an app on Heroku.

12. Record Sharing in Partner Community 
1. Communities can have separate OWD through Default External Access.

2. Role Hierarchy can be set using "Number of partner roles" under Community Settings.
Note: Maximum Number of partner roles can be set to 3.

3. Sharing Rules can be created. Supports both Criteria Based and Owner Based sharing rules.

4. Sharing Sets can be used -

5.  Owner of the account(Channel Sales Manager - Usually an internal Salesforce user with full Salesforce license) have access to all the records associated to it.

6. Account Relationships and Account Relationship Data Sharing Rules-

13. Live Agent
Live Agent API Endpoint URL is available in Live Agent Settings.

Enable Live Agent check box on the user record.

1. Create Skills.
2. Create Chat Button.
Chat Button - Standard Chat Button
Automated Invitation - Pop Up Chat Button
Customer Time-Out(seconds) - End Chat after time-out
Cusotmer Time-Out Warning(seconds) - Warning for customer for inactivity

Chat Routing Options -

3. Live Agent Configurations
Sneak Peak Enabled - Enable it to show "Typing"
Notifications Enabled - Indicates whether to display a desktop alert when an agent receives a new chat request.
Visitor Blocking Enabled - Indicates whether an agent can block visitors from an active chat within the Salesforce console.
Assistance Flag Enabled - Indicates whether an agent can send a request for help (“raise a flag”) to a supervisor.
Chat Conferencing Enabled - Indicates whether agents can invite other agents to join them in customer chats.

3. Create Deployments.
Allow Access to Pre-Chat API - Allows to use VF page for pre-chat form

1. Works only with Console App.
2. Make sure Include Live Agent in this App check box is enabled to have Live Agent in the app.
3. When an agent accepts a transferred chat, only the chat is transferred to the agent.
Ownership of related records, such as a case, aren't transferred to the agent.

Live Agent Supervisor tab access is required to view as Supervisor.
Supervisor can sneak peak if it was enabled.
Supervisor can whisper messages to the agent if it was enabled.

14. In Omni-Channel, Assignment Rules, Auto-Response Rules, Escalation Rules, and Workflow Rules trigger policy
Automation rules, such as assignment, auto-response, escalation, and workflow rules, aren’t triggered when Omni-Channel routes a work item to an agent and the agent accepts the work.

When an agent accepts the work and then edits and saves the work item record, automation rules are triggered.

15.What is the difference between Live Agent and Embedded Service/Snap-Ins?Embedded Service chat (formerly known as snap-in)
Live Agent
Live Agent connects customers with your support agents through web-based chat.
In order to browse the website when they are chatting with the agent, they have to minimize the chat window. But, in embedded service, chat stays on the same window even when they navigate and browse the website.

Embedded Service/Snap-Ins
This uses Live Agent but, with a simpler setup.
Lightning Experience must be enabled to set up Embedded Service.
Users can get answers to their questions by chatting with an agent while browsing the site.
After you’ve set up Chat and Omni-Channel to work together in Lightning Experience, give your customers a better chat experience with Embedded Service and Einstein Bots. Embedded Service lets you create a pre-chat form and custom branding with little to no code. Embed the chat window on your website and both your desktop and mobile customers can have the same chat experience. Einstein Bots lets you connect customers to an automated chat bot to answer questions and solve straightforward issues.

lightning:datatable with header and footer in Salesforce Lightning Component

Sample Code:

Apex Class:

  1. public class AccountListController {  
  3.     @AuraEnabled  
  4.     public static List < Account > fetchAccts() {  
  6.         return [ SELECT Id, Name, Industry, Type FROM Account LIMIT 100 ];  
  8.     }  
  10. }  

Lightning Component:

  1. <aura:component implements="force:appHostable" controller="AccountListController" >  
  3.     <aura:attribute type="Account[]" name="acctList"/>  
  4.     <aura:attribute name="mycolumns" type="List"/>  
  6.     <aura:handler name="init" value="{!this}" action="{!c.fetchAccounts}"/>  
  8.             <lightning:card footer="Only 100 accounts records are loaded" title="Accounts">  
  9.                 <p class="slds-p-horizontal_small">  
  11.                     <lightning:datatable data="{! v.acctList }"   
  12.                                          columns="{! v.mycolumns }"   
  13.                                          keyField="id"  
  14.                                          hideCheckboxColumn="true"/>  
  16.                 </p>  
  17.             </lightning:card>     
  19. </aura:component>  

Lightning JavaScript Controller:

  1. ({  
  3.     fetchAccounts : function(component, event, helper) {  
  5.         component.set('v.mycolumns', [  
  6.             {label: 'Account Name', fieldName: 'Name', type: 'text'},  
  7.                 {label: 'Industry', fieldName: 'Industry', type: 'text'},  
  8.                 {label: 'Type', fieldName: 'Type', type: 'Text'}  
  9.             ]);  
  10.         var action = component.get("c.fetchAccts");  
  11.         action.setParams({  
  12.         });  
  13.         action.setCallback(this, function(response) {  
  14.             var state = response.getState();  
  15.             if (state === "SUCCESS") {  
  16.                 component.set("v.acctList", response.getReturnValue());  
  17.             }  
  18.         });  
  19.         $A.enqueueAction(action);  
  21.     }  
  23. })  


Case Teams in Salesforce

A case team is a group of people that work together to solve cases. For example, a case team can include support agents, support managers, and product managers.

Users added to the case through Case Teams gets access to the Case based on the access leavel defined.

Case Team Role contains Visible in Customer Portal value.
Visible in Customer Portal check box allows to hide and show in the communities.

Add Team action
Requires Predefined Case Teams.
Predefined Case Teams can be created by an Admin under Setup --> Case Teams --> Predefined Case Teams.

Add Member action
Allows to add individual users to the Case.

Admins can predefine case teams so that you can quickly add people who you frequently work with.

Case Hierarchy in Salesforce Lightning

When a case is associated with a parent case, it signifies a relationship between cases.

1. Add Parent Case field to the page layout to link cases.

2. Add View Case Hierarchy action to the page layout to view the hierarchy.

3. Configure Case Hierarchy Columns. By default, the hierarchy view uses the same columns as the recently viewed cases list view.