July 31, 2019

Custom Actions in lightning:listView in Salesforce

1. Create a List View. Get the List API Name.


2. Create a Custom Lightning Component.

Component:

  1. <aura:component implements="force:appHostable" >  
  2.       
  3.     <div class = "slds-box slds-theme_default">   
  4.         <div class="slds-clearfix">  
  5.         <div class="slds-float--right">  
  6.             <lightning:button label="New" title="New" onclick="{! c.handleClick }"/>  
  7.         </div>  
  8.         </div>  
  9.           
  10.         <div>  
  11.             <lightning:listView aura:id="listViewExtEmps"  
  12.                                 objectApiName="Employee__c"  
  13.                                 listName="External_Employees"  
  14.                                 rows="5"  
  15.                                 showSearchBar="true"  
  16.                                 showActionBar="false"  
  17.                                 enableInlineEdit="true"  
  18.                                 showRowLevelActions="true"/>  
  19.         </div>  
  20.           
  21.     </div>  
  22.       
  23. </aura:component>  

Component Controller:

  1. ({  
  2.       
  3.     handleClick : function (cmp, event, helper) {  
  4.           
  5.         var createRecordEvent = $A.get('e.force:createRecord');  
  6.         if ( createRecordEvent ) {  
  7.               
  8.             createRecordEvent.setParams({  
  9.                 'entityApiName''Employee__c',  
  10.                 'recordTypeId' : '0123i000000HSiWAAW'  
  11.             });  
  12.             createRecordEvent.fire();  
  13.               
  14.         } else {  
  15.               
  16.             /* Create Record Event is not supported */  
  17.             alert("Record creation is not supported");  
  18.               
  19.         }  
  20.           
  21.     }  
  22.       
  23. })  

3. Create a Lightning Tab.


Output:


July 30, 2019

How to prepare for JAVASCRIPT certification?

Unconvert Leads in Salesforce

Once the Lead is converted, we cannot unconvert it in Salesforce.

Using View and Edit Converted Leads permission in the Profile, users can edit the Leads. But, users can’t unconvert leads. Even with this permission if the user updates the Lead to different status, ConvertedAccountId and ConvertedOpportunityId fields cannot be updated through trigger. These are system fields.

It is better to delete the opportunity and create new Lead.

Check the below link for View and Edit Converted Leads permission in the Profile.
http://www.infallibletechie.com/2018/10/profile-permission-to-view-and-edit.html

Vote for the below Idea
https://success.salesforce.com/ideaView?id=08730000000ksj0AAA

July 26, 2019

How to insert Data using Flows in Salesforce

Sample Flow:


1. Go to Flows in Setup.

2. Click New Flow.

3. Go to Manager and click New Resource. Enter a name, select Record as Data Type and select the object.


4. Drag and Drop Screen element.

5. Add Text box, Picklist and Long Text Area as below and configure it.



6. For Industry picklist, select Industry picklist from the Account object in the choice.



7. Set the Assignment element like below.


8. Set the Create Records element like below.


9. Set the success screen as below.


10. Set the fault screen as below.


July 24, 2019

How to easily search a report in Salesforce?

Salesforce Classic:


Salesforce Lightning:


Classic Email Templates drop-down is missing in Salesforce Lightning Experience

If Classic Email Templates drop-down is missing in Salesforce Lightning Experience, make sure the Email Template and Related to fields are added to the quick action layout.


Email Quick action with Related To and Email Template:



Email Quick action without Related To and Email Template:



How to use onsuccess action in lightning-record-edit-form?

Sample Code:

Lightning Web Component:


  1. <template>  
  2.   
  3.     <lightning-record-edit-form record-id="0013i000003DPlvAAG"  
  4.                                 object-api-name="Account"  
  5.                                 onsuccess={handleSuccess}>  
  6.   
  7.         <lightning-messages></lightning-messages>  
  8.         <lightning-output-field field-name="Name"></lightning-output-field>  
  9.         <lightning-input-field field-name="Industry"></lightning-input-field>  
  10.         <lightning-input-field field-name="Description"></lightning-input-field>  
  11.         <lightning-input-field field-name="Rating"></lightning-input-field>  
  12.         <lightning-button class="slds-m-top_small"  
  13.                           variant="brand"  
  14.                           type="submit"  
  15.                           name="update"  
  16.                           label="Update">  
  17.         </lightning-button>  
  18.   
  19.     </lightning-record-edit-form>      
  20.       
  21. </template>  

Lightning Web Component Controller:


  1. import { LightningElement } from 'lwc';  
  2.   
  3. export default class AccountEditLWC extends LightningElement {  
  4.   
  5.     handleSuccess( event ) {  
  6.   
  7.         const payload = event.detail;  
  8.         alert( JSON.stringify( payload ) );  
  9.   
  10.     }  
  11.   
  12. }  

Output:


July 23, 2019

How to notify additional users when a Case receives Inbound Emails in Salesforce?

1. Create Last Inbound Email Received Date Time Field.


2. Create a Workflow Rule on EmailMessage object.


3. Create a Field Update on EmailMessage object.


4. Create a Workflow Rule on Case Object.


5. Create Email Alert on Case Object.


Report on Salesforce Mobile or Salesforce1 Usage

1. Create a custom report type.

2. Select Users as the Primary Object.


3. Select Identity Event Logs (User) in Relate Another object.


4. In the report filter add, App: Connected App Name equals Salesforce for Android,Salesforce for iOS.




July 22, 2019

Salesforce Interview Questions with Answers Part 57

1. Splunk and Salesforce

Install Splunk App for Salesforce using the below URL.
https://splunkbase.splunk.com/app/1931/

We can check the below

1. Apex Pages performance
2. Apex Classes performance
3. Detect Security Threats
4. Reports and Dashboards usage and performance
5. Trigger Chatter feed to a group in Salesforce

2. What is a crosswalk table?

Crosswalk table is a reference table which gets all the columns from two or more different tables.

Table1

ID   | Name     | Address     | Zip   | PhoneNumber
-----------------------------------------------------
IN11 | Brad Bob | 763 Park St | 25896 | 999-789-1234
-----------------------------------------------------

Table2

ID   | Name     | Address     | Zip   | PhoneNumber
-----------------------------------------------------
IN22 | Brad Bob | 763 Park St | 25896 | 999-789-1234
-----------------------------------------------------

Sample Crosswalk

Table1ID | Table2ID
---------------------
IN11     | IN22
---------------------

Query:
SELECT Table1.ID AS Table1ID, Table2.ID AS Table2ID
FROM Table1
INNER JOIN Table2 ON Table1.Name = Table2.Name
  AND Table1.Address = Table2.Address
  AND Table1.Zip = Table2.Zip
  AND Table1.PhoneNumber = Table2.PhoneNumber

3. Why Lightning Web Component is open source?

Lightning Web Components framework doesn’t have dependencies on the Salesforce platform. Instead, Salesforce-specific services are built on top of the framework. What that layered architecture means is that you can now use the Lightning Web Components framework to build web apps that run anywhere.

In the past, developers often had to use different frameworks to build different sides of an application. For example, you’d use Aura to build the employee-facing side of an application on Salesforce and React, Angular or Vue to build the customer engagement side of the application on Heroku or any other platform. Today, you can use Lightning Web Components to build both sides of the application. The benefits are significant: you only need to learn a single framework and you can share code between apps. And because Lightning Web Components is built on the latest web standards, you know you are using a cutting-edge framework based on the latest patterns and best practices.

4. Difference between Primary tab and Subtab in Salesforce Service Console

Primary Tab 
Primary tabs are the records opened from searches and list views.

Subtab
Subtabs display related records opened from within the open primary tab you are already working from.

Example: If you have a case open and click on the name of the Opportunity, the Opportunity record will open in a sub-tab.

5. How to access Metrics for Your Visualforce Pages in Salesforce?

Using VisualforceAccessMetrics, you can track the number of views each Visualforce page in your org receives in a 24-hour time period. To find out how many views a page got over the course of multiple days, you can query multiple VisualforceAccessMetrics objects for the same ApexPageId.

SOQL:
SELECT ApexPageId, ApexPage.Name, DailyPageViewCount, Id, ProfileId, MetricsDate, LogDate FROM VisualforceAccessMetrics ORDER BY ApexPage.Name

LogDate provides the date that the page access was logged. This parameter is available for release 216 and later.

ProfileId is the ID of the profile associated with the users who accessed the page. This parameter is available for release 216 and later.

ApexPageId is the ID of the tracked Visualforce page.

DailyPageView tracks the daily page view count in the DailyPageViewCount field.

MetricsDate is the date the metrics were collected is specified in MetricsDate.

Note:
Page views are tallied the day after the page is viewed, and each VisualforceAccessMetrics object is removed after 90 days.

6. Salesforce Scope Parameter

Salesforce uses below scopes.

api - Allows access to the current, logged-in user’s account using APIs, such as REST API and Bulk API. This value also includes chatter_api, which allows access to Chatter REST API resources.

chatter_api - Allows access to Chatter REST API resources only.

custom_permissions - Allows access to the custom permissions in an organization associated with the connected app, and shows whether the current user has each permission enabled.

full - Allows access to all data accessible by the logged-in user, and encompasses all other scopes. full does not return a refresh token. You must explicitly request the refresh_token scope to get a refresh token.

id - Allows access to the identity URL service. You can request profile, email, address, or phone, individually to get the same result as using id; they are all synonymous.

openid - Allows access to the current, logged in user’s unique identifier for OpenID Connect apps.

Use the openid scope in the OAuth 2.0 user-agent flow and the OAuth 2.0 web server authentication flow to receive a signed ID token conforming to the OpenID Connect specifications in addition to the access token.

refresh_token - Allows a refresh token to be returned when you are eligible to receive one. Then the app can interact with the user’s data while the user is offline, and is synonymous with requesting offline_access.

visualforce - Allows access to customer-created Visualforce pages. Doesn’t allow access to standard Salesforce UIs.

web - Allows the ability to use the access_token on the web, and includes visualforce, allowing access to customer-created Visualforce pages.

Reference Link - https://help.salesforce.com/articleView?id=sso_provider_addl_params_scope.htm&type=5

7. Streaming API Notifications Sent in Reverse Order Within a Transaction

In general, event notifications are delivered in the order of record changes. One exception is that when a record triggers multiple notifications within the same transaction, the last notifications are delivered first.
For example, let’s say you have a PushTopic for insertions and updates of contact records, and the PushTopic query selects fieldA. If a contact is inserted and then an Apex trigger or workflow updates fieldA in the same transaction, the order of notifications sent is:

Notification for the update of fieldA
Notification for the insertion of the record
In this case, the order of notifications depends on the order in which the Lightning Platform commits transactions.

8. What is the use of Sharing Set in Salesforce Community?

A sharing set gives community users access to records that are associated with their accounts or contacts based on their user profiles.

Note:
The Available Objects list excludes:

Objects with an organization-wide sharing setting of Public Read/Write
Custom objects that don’t have an account or contact lookup field

9. lightning:relativeDateTime

When you provide a timestamp or JavaScript Date object, lightning:relativeDateTime displays a string that describes the relative time between the current time and the provided time.

https://www.infallibletechie.com/2019/06/lightningrelativedatetime.html

10. How to use WHERE condition in SOSL?

public class SOSLController {

    public static List < List < SObject > > searchAccountContactLead( String strSearch ) {
 
        String searchQuery = 'FIND \'' + strSearch + '*\' IN ALL FIELDS RETURNING Account( Id, Name WHERE Industry = \'Apparel\' ), Contact, Lead';
        return search.query( searchQuery );
 
    }
 
}

11. @AuraEnabled( cacheable = true )

Marking a method as storable improves your component’s performance by quickly showing cached data from client-side storage without waiting for a server trip. If the cached data is stale, the framework retrieves the latest data from the server. Caching is especially beneficial for users on high-latency, slow, or unreliable connections, such as 3G networks.

Prior to Winter ’19, to cache data returned from an Apex method, you had to call setStorable() in JavaScript code on every action that called the Apex method. Now you can mark the Apex method as storable (cacheable) and get rid of any setStorable() calls in JavaScript code.

12. Adding SOSL Queries to Unit Tests

To ensure that test methods always behave in a predictable way, any Salesforce Object Search Language (SOSL) query that is added to an Apex test method returns an empty set of search results when the test method executes. If you do not want the query to return an empty list of results, you can use the Test.setFixedSearchResults system method to define a list of record IDs that are returned by the search. All SOSL queries that take place later in the test method return the list of record IDs that were specified by the Test.setFixedSearchResults method. Additionally, the test method can call Test.setFixedSearchResults multiple times to define different result sets for different SOSL queries. If you do not call the Test.setFixedSearchResults method in a test method, or if you call this method without specifying a list of record IDs, any SOSL queries that take place later in the test method return an empty list of results.

The list of record IDs specified by the Test.setFixedSearchResults method replaces the results that would normally be returned by the SOSL query if it were not subject to any WHERE or LIMIT clauses. If these clauses exist in the SOSL query, they are applied to the list of fixed search results.

Note:
1. Although the record may not match the query string in the FIND clause, the record is passed into the RETURNING clause of the SOSL statement.
2. If the record matches the WHERE clause filter, the record is returned. If it does not match the WHERE clause, no record is returned.

https://www.infallibletechie.com/2019/06/adding-sosl-queries-to-unit-tests.html 

13. Sales Cadences in Salesforce

For reps, sales cadences bring together all their pending activities in one view and log activities as reps complete them. After reps start using sales cadences, managers can report on which cadences result in the best sales outcomes.

For example, a sales manager can guide reps to make two back-to-back calls to the prospect, wait half a day, and then call again or send an email. This sequence is a best practice for optimizing prospecting results.

It is available with High Velocity Sales, which is available for an extra cost.

For more information check https://help.salesforce.com/articleView?id=hvs_cadences.htm&type=5

14. Opportunity Age and Stage Duration in Salesforce

Age
For an open opportunity, the number of days since the opportunity was created. For a closed opportunity, the number of days between the creation date and the closed date.

Stage Duration
Stage Duration is the total number of days an opportunity is in a particular sales stage, specifically from the date when the opportunity changed to current stage until today.

Limitations:
1. Available only through standard reports.
2. We cannot add it to the page layout.

15. DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id

Check whether you are affected by this known issue - https://success.salesforce.com/issues_view?id=a1p30000000T5hTAAS. If yes, contact Salesforce support.

DML Error
If you're getting this error from a DML operation, then check the below

1. Check whether there are any fields with Unique attribute selected. If yes, check whether you are entering unique value to this field while doing data loading. Also, check whether any processes are updating this unique field value. Setting debug log, helps to find it or search through the metadata.
2. Check this - https://developer.salesforce.com/forums/?id=906F00000009A2vIAE

Deployment Error
If you're getting this error while trying to deploy. then check the below

1. Check whether there are any fields with Unique attribute selected. If yes, check whether test class is creating unique value for these fields.
2. Check whether you are trying to deploy picklist field. If yes, make sure the value is not inactive in the target org.

16. What’s an Integrated Development Environment (IDE)? 

Typically, it’s a program that gives developers a collection of tools including source code editor, build automation, and debugging.

17. How to close the quick action popup and refresh the page from custom Salesforce Lightning Component?

Use the below methods to close the quick action popup and refresh the page from custom Salesforce Lightning Component.

                $A.get("e.force:closeQuickAction").fire();
                $A.get('e.force:refreshView').fire();

18. Hourly limit exceeded for processing workflow time triggers

1,000 workflow time triggers per hour is the current Salesforce limit for time trigger actions.

If you have 1100 time trigger actions to be executed between 7am and 8am, Salesforce executes 1000 between 7am and 8am and remaining 100 after 8am. Once the limit is reached Salesforce defers processing and resumes in the next hour.

Salesforce limits the number of total and active rules in your org, the number of time triggers and actions per rule. It also processes a limited number of daily emails and hourly time triggers.

When workflows approach or exceed certain limits, Salesforce sends a warning email to the default workflow user or if the default workflow user isn't set then to an active system administrator.

HourlyTimeBasedWorkflow from OrgLimits.getAll() can give you the current limit.

Check the below link for more limits

https://help.salesforce.com/articleView?id=workflow_limits.htm&type=5

July 20, 2019

What is Leaf node?

In computer science, a 'tree' is a widely used abstract data type (ADT)—or data structure implementing this ADT—that simulates a hierarchical tree structure, with a root value and subtrees of children with a parent node, represented as a set of linked nodes.

A node is a structure which may contain a value or condition, or represent a separate data structure (which could be a tree of its own). Each node in a tree has zero or more child nodes, which are below it in the tree (by convention, trees are drawn growing downwards). A node that has a child is called the child's parent node (or ancestor node, or superior). A node has at most one parent.

An internal node (also known as an inner node, 'inode' for short, or branch node) is any node of a tree that has child nodes. Similarly, an external node (also known as an outer node, leaf node, or terminal node) is any node that does not have child nodes.


July 19, 2019

Chatter Feeds sharing in Salesforce

A chatter post inherits its sharing access from the parent entity.

If OWD is private for an object, then users that the object is shared to can view the record or post.

If the records are shared through Sharing rules or manual sharing, then the users can view the feeds on the records. 

So, if an user have access to the record, then the user can view all the chatter feeds related to that record.

Follow people and records to see updates about them in Chatter feeds on profiles, groups, the Chatter tab, topic detail pages, and on record detail pages.

July 18, 2019

How to attach multiple attachments using Send An Email button in Salesforce?

AppExchange products are below

https://appexchange.salesforce.com/appxListingDetail?listingId=a0N30000003IzEDEA0

https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000B4BAdEAN

Note:
Currently it is available out of the box in Lightning.

https://success.salesforce.com/ideaView?id=08730000000Bp7O

1. Open a case and click Send an Email button.


2. Click Attach File.


3. We can select only one file at a time. So, select a file and click Attach to Email button. Add multiple files like this and click Done button.


4. Click Done and view the email.


July 17, 2019

How to avoid instance name in the Document URLs in Salesforce?

Make sure My Domain is enabled in your org.

Check the below URL, if My Domain is not enabled.

http://www.infallibletechie.com/2013/04/how-to-register-domain-instead-of.html

Image - https://mydomain--c.documentforce.com/servlet/servlet.ImageServer?id={id}&oid={OrgId}

PDF - https://mydomain--c.documentforce.com/servlet/servlet.FileDownload?file={id}