December 31, 2018

How to create Dataflow in Salesforce?

1. Go to Data Manager.


2. Click Create Dataflow in Dataflows & Recipes.


How to customize a Community User's My Profile or My Account page in a Community?

1. Go to Community Builder.

2. Select User Profile page.


What is the use of ReplayId in Platform Event in Salesforce?

Each event message is assigned an opaque ID contained in the ReplayId field. The ReplayId field value, which is populated by the system, refers to the position of the event in the event stream. Replay ID values are not guaranteed to be contiguous for consecutive events. For example, the event following the event with ID 999 can have an ID of 1,025. A subscriber can store a replay ID value and use it on resubscription to retrieve events that are within the retention window. For example, a subscriber can retrieve missed events after a connection failure. Subscribers must not compute new replay IDs based on a stored replay ID to refer to other events in the stream.


December 30, 2018

How to make multiple fields Required or Read Only in the page layout in Salesforce?

1. Edit the page layout.

2. Select multiple fields from the page layout by pressing command button.

3. Hover over one of the highlighted fields and click Wrench icon to edit them all.


SOQL to find whether users have logged in to the Sandbox

Sample SOQL:


SELECT Id, LoginTime, UserId FROM LoginHistory WHERE DAY_ONLY( LoginTime ) = LAST_N_DAYS:31 AND UserId != 'YOUR USER ID' ORDER BY LoginTime DESC LIMIT 100


I have checked whether any of the users have logged in for the past 31 days in the query.


How to Enforce and Bypass sharing rules in Duplicate Rule in Salesforce?

Specify how your organization's sharing rules determine which records the matching rule compares.

Enforce sharing rules: The matching rule compares only records that the user has access to, and the resulting list of possible duplicates includes only records the user has access to.

Bypass sharing rules: The matching rule compares all records, regardless of user access, but the resulting list of possible duplicates includes only records the user has access to.


December 28, 2018

How to Enable Replication in Salesforce Analytics?

Replication uses your existing dataflows to determine which objects and fields to replicate. When you enable replication, Analytics validates these dataflows and displays any errors it finds. Fix errors before you continue.

Extracts local and external data in advance for use in dataflows and recipes.

1. Go to Analytics Settings.


2. Check Enable Replication.


How to get session id in Salesforce?

1. Use POST method.

2. Set the end point.

Sandbox - https://test.salesforce.com/services/Soap/u/35.0
Production - https://login.salesforce.com/services/Soap/u/35.0

Use custom domain URL if my domain is enabled and prevent login from test or login.salesforce.com is enabled.

3. Set your headers as below.

SOAPAction = ""
Content-Type = text/xml



4. Use the below as body.

  1. <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com">  
  2.   
  3.    <soapenv:Body>  
  4.   
  5.       <urn:login>  
  6.   
  7.          <urn:username>Login ID</urn:username>  
  8.   
  9.          <urn:password>Password</urn:password>  
  10.   
  11.       </urn:login>  
  12.   
  13.    </soapenv:Body>  
  14.   
  15. </soapenv:Envelope>  


5. Get the SessionId.


How to use Topics in List View in Salesforce?

While creating list view, include Topics in the filter condition.


How to set Component Visibility Based on Standard and Custom User Permissions in Salesforce?

Now you can make your Lightning pages more dynamic by configuring component visibility filters based on the permissions of the person viewing the page. For example, you can create a rule for a component to display for users with a specific permission, but it’s hidden for everyone else. Component visibility filters are supported for standard components, custom components, and components from AppExchange.



December 27, 2018

How to find duplicate Contacts from Lead in Salesforce?

1. Create a Contact Matching Rule.


2. Activate the Matching Rule.

3. Create a Lead Duplicate Rule using the Contact Matching Rule.


4. Activate the Duplicate Rule.

5. Open a Lead record which has same email of a Contact record. In my case there are two contact records which has same email. Click Find Duplicates.


6. It will show the duplicate contact records.


Salesforce IOT

Harness data from connected devices and services to drive real-time engagement with your customers.

1. Go to Getting Started under Salesforce IOT.


2. Enable Salesforce IOT.


Do the below trailhead to get started


Quick Text in Salesforce

Say Goodbye to Copy and Paste and Hello to Quick Text from Salesforce!!!

To enable Quick Text, follow the below steps

1. Go to Quick Text Settings.


2. Enable Quick Text.


To use Quick Text

From Email:


From Log a Call:


From New Event:


December 25, 2018

External Services in Salesforce

External Services is a feature within Salesforce that leverages declarative tools to connect to an external endpoint, such as a credit service provider, and bring its logic into Salesforce.

Go to External Services from force.com setup to set it up. It's easy to set up with point and clicks.


Use External Services to connect to a service of your choice, invoke methods based on the external source via a flow, and import data from the service into Salesforce—all with the help of an easy-to-use wizard.

Use External Services to connect your Salesforce org to a service of your choice. Invoke methods based on the external source via a flow. Import data from the service into Salesforce. You can do all this with the help of an easy-to-use wizard.

Trailhead link - https://trailhead.salesforce.com/en/modules/external-services

Apex Actions in Flows:


How to delete all debug logs from an org in Salesforce?

Run the below code in Developer Console using Open Execute Anonymous Window

delete [ SELECT Id FROM ApexLog ];


Code Coverage for Custom Metadata Type usage in Apex Class in Salesforce

Custom Metadata Type:



Custom Metadata Type Data:



Sample Apex class and test class:

public class Sample {

    public static Sample__mdt getSampleValue( String strName ) {
    
        return [ SELECT DeveloperName, Description__c FROM Sample__mdt WHERE DeveloperName =: strName ];
        
    }

}

@isTest
public class SampleTest {

    static testMethod void test() {
    
        Sample__mdt objSample = Sample.getSampleValue('Test');
        system.assertEquals('Test', objSample.DeveloperName);
        system.assertEquals('Test', objSample.Description__c);
        
    }

}

Output:


December 24, 2018

How to get all Phone Fields in Salesforce?

Sample Code:


  1. Set < String > listsObjs = new Set < String > {'Account''Lead'};      
  2. Map<String, Schema.SObjectType > globalDescription = Schema.getGlobalDescribe();   
  3.         
  4. for ( String obj : listsObjs ) {  
  5.   
  6.     Schema.sObjectType objType = globalDescription.get( obj );  
  7.     Schema.DescribeSObjectResult r1 = objType.getDescribe();   
  8.     Map<String , Schema.SObjectField > mapFieldList = r1.fields.getMap();    
  9.   
  10.     for ( Schema.SObjectField field : mapFieldList.values() ) {    
  11.       
  12.         Schema.DescribeFieldResult fieldResult = field.getDescribe();    
  13.         String fieldLabel = fieldResult.getLabel().toLowerCase();  
  14.         Schema.DisplayType fielddataType = fieldResult.getType();  
  15.   
  16.         if ( fielddataType == Schema.DisplayType.Phone ) {  
  17.           
  18.             System.debug( objType + '.' + fieldResult.getName() );  
  19.               
  20.         }  else if ( fieldLabel.contains( 'phone' ) && ! fieldResult.isCalculated() ) {  
  21.           
  22.             System.debug ( objType + '.' + fieldResult.getName() );  
  23.           
  24.         }  
  25.           
  26.     }  
  27.       
  28. }  

In the Developer Console, select Debug Only to see the debug logs.


December 22, 2018

How to change record values to Blank or NULL using Data Loader in Salesforce?

Regular Data Load:

1.  Open Data Loader.

2.  Click Settings.

3.  Select Insert Null Values.


BULK API Load:

In case of Bulk API Enabled scenario, use #N/A​ in the columns. To set a field value to null when the Use Bulk API option is selected, use a field value of #N/A​.


December 21, 2018

How to get all Address Fields in Salesforce?

Sample Code:


  1. Set < String > listsObjs = new Set < String > {'Account''Lead'};      
  2. Map<String, Schema.SObjectType > globalDescription = Schema.getGlobalDescribe();   
  3.         
  4. for ( String obj : listsObjs ) {  
  5.   
  6.     Schema.sObjectType objType = globalDescription.get( obj );  
  7.     Schema.DescribeSObjectResult r1 = objType.getDescribe();   
  8.     Map<String , Schema.SObjectField > mapFieldList = r1.fields.getMap();    
  9.   
  10.     for ( Schema.SObjectField field : mapFieldList.values() ) {    
  11.       
  12.         Schema.DescribeFieldResult fieldResult = field.getDescribe();    
  13.         String fieldLabel = fieldResult.getLabel().toLowerCase();  
  14.         Schema.DisplayType fielddataType = fieldResult.getType();  
  15.   
  16.         if ( ( fieldLabel.contains( 'address' ) || fieldLabel.contains( 'state' )   
  17.               || fieldLabel.contains( 'street' ) || fieldLabel.contains( 'city' )   
  18.               || fieldLabel.contains( 'postal' ) || fieldLabel.contains( 'zip' ) )   
  19.             && ! fieldResult.isCalculated() ) {  
  20.           
  21.             System.debug ( objType + '.' + fieldResult.getName() );  
  22.           
  23.         }  
  24.           
  25.     }  
  26.       
  27. }  

In the Developer Console, select Debug Only to see the debug logs.



How to add new line in Long Text Area field using Apex in Salesforce?

\n is used to add new line in Long Text Area field using Apex in Salesforce.

Sample Code:


  1. trigger AccountTrigger on Account ( before update ) {  
  2.   
  3.     for ( Account acc : trigger.new ) {  
  4.       
  5.         if ( acc.CustomerPriority__c != trigger.oldMap.get(acc.Id).CustomerPriority__c ) {  
  6.           
  7.             if  ( acc.Long__c == null )  
  8.                 acc.Long__c = 'Changed Customer Priority from ' + trigger.oldMap.get(acc.Id).CustomerPriority__c + ' to ' + acc.CustomerPriority__c + ' on ' + system.now();   
  9.             else   
  10.                 acc.Long__c = acc.Long__c + '\n Changed Customer Priority from ' + trigger.oldMap.get(acc.Id).CustomerPriority__c + ' to ' + acc.CustomerPriority__c + ' on ' + system.now();  
  11.              
  12.         }  
  13.               
  14.     }  
  15.       
  16. }  

Output:


Transaction Security setting missing in Salesforce

Transaction Security in Salesforce is

Available in: Salesforce Classic and Lightning Experience
Available in: Enterprise, Performance, Unlimited, and Developer Editions

Requires purchasing Salesforce Shield or Salesforce Event Monitoring add-on subscriptions.

Once Salesforce Shield or Salesforce Event Monitoring add-on subscription is purchased, Salesforce will enable this option under Security in Setup.


December 20, 2018

How to disable global search in Salesforce classic?

1. Go to Chatter Settings.


2. Disable Chatter Settings.




How to enable Field Service in Salesforce?

1. Go to Field Service Settings.


2. Check Enable Field Service Lightning and click Save button.


The default value for Search work order fields when suggesting article and Search work order line item fields when suggesting articles is Subject. Change it if required to a different field. You can select multiple fields too.

How to hide code mini map or highlight on the right hand side in Visual Studio Code?

Go to View --> Unselect Toggle Minimap.


December 19, 2018

Package.xml to get all the metadata using Visual Studio Code for Salesforce

Package.xml:

  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>  
  2. <Package xmlns="http://soap.sforce.com/2006/04/metadata">  
  3.     <types>  
  4.         <members>*</members>  
  5.         <name>ApexClass</name>  
  6.     </types>  
  7.     <types>  
  8.         <members>*</members>  
  9.         <name>ApexComponent</name>  
  10.     </types>  
  11.     <types>  
  12.         <members>*</members>  
  13.         <name>ApexPage</name>  
  14.     </types>  
  15.     <types>  
  16.         <members>*</members>  
  17.         <name>ApexTestSuite</name>  
  18.     </types>  
  19.     <types>  
  20.         <members>*</members>  
  21.         <name>ApexTrigger</name>  
  22.     </types>  
  23.     <types>  
  24.         <members>*</members>  
  25.         <name>AuraDefinitionBundle</name>  
  26.     </types>  
  27.     <types>  
  28.         <members>*</members>  
  29.         <name>StaticResource</name>  
  30.     </types>  
  31.     <types>  
  32.         <members>*</members>  
  33.         <name>CustomApplication</name>  
  34.     </types>  
  35.     <types>  
  36.         <members>*</members>  
  37.         <name>ApprovalProcess</name>  
  38.     </types>  
  39.     <types>  
  40.         <members>*</members>  
  41.         <name>AssignmentRule</name>  
  42.     </types>  
  43.     <types>  
  44.         <members>*</members>  
  45.         <name>AuthProvider</name>  
  46.     </types>  
  47.     <types>  
  48.         <members>*</members>  
  49.         <name>CallCenter</name>  
  50.     </types>  
  51.     <types>  
  52.         <members>*</members>  
  53.         <name>Community</name>  
  54.     </types>  
  55.     <types>  
  56.         <members>*</members>  
  57.         <name>ConnectedApp</name>  
  58.     </types>  
  59.     <types>  
  60.         <members>*</members>  
  61.         <name>CustomApplicationComponent</name>  
  62.     </types>  
  63.     <types>  
  64.         <members>*</members>  
  65.         <name>CustomMetadata</name>  
  66.     </types>  
  67.     <types>  
  68.         <members>*</members>  
  69.         <name>CustomPermission</name>  
  70.     </types>  
  71.     <types>  
  72.         <members>*</members>  
  73.         <name>Dashboard</name>  
  74.     </types>  
  75.     <types>  
  76.         <members>*</members>  
  77.         <name>DataCategoryGroup</name>  
  78.     </types>  
  79.     <types>  
  80.         <members>*</members>  
  81.         <name>Document</name>  
  82.     </types>  
  83.     <types>  
  84.         <members>*</members>  
  85.         <name>EmailTemplate</name>  
  86.     </types>  
  87.     <types>  
  88.         <members>*</members>  
  89.         <name>EntitlementProcess</name>  
  90.     </types>  
  91.     <types>  
  92.         <members>*</members>  
  93.         <name>EntitlementTemplate</name>  
  94.     </types>  
  95.     <types>  
  96.         <members>*</members>  
  97.         <name>FlexiPage</name>  
  98.     </types>  
  99.     <types>  
  100.         <members>*</members>  
  101.         <name>Flow</name>  
  102.     </types>  
  103.     <types>  
  104.         <members>*</members>  
  105.         <name>Group</name>  
  106.     </types>  
  107.     <types>  
  108.         <members>*</members>  
  109.         <name>HomePageComponent</name>  
  110.     </types>  
  111.     <types>  
  112.         <members>*</members>  
  113.         <name>HomePageLayout</name>  
  114.     </types>  
  115.     <types>  
  116.         <members>*</members>  
  117.         <name>CustomLabels</name>  
  118.     </types>  
  119.     <types>  
  120.         <members>*</members>  
  121.         <name>Layout</name>  
  122.     </types>  
  123.     <types>  
  124.         <members>*</members>  
  125.         <name>MilestoneType</name>  
  126.     </types>  
  127.     <types>  
  128.         <members>Account</members>  
  129.         <members>AccountContactRole</members>  
  130.         <members>Activity</members>  
  131.         <members>Asset</members>  
  132.         <members>AssetRelationship</members>  
  133.         <members>AssistantProgress</members>  
  134.         <members>Campaign</members>  
  135.         <members>CampaignMember</members>  
  136.         <members>Case</members>  
  137.         <members>CaseContactRole</members>  
  138.         <members>CaseMilestone</members>  
  139.         <members>ChatterActivity</members>  
  140.         <members>CollaborationGroup</members>  
  141.         <members>CollaborationGroupMember</members>  
  142.         <members>Contact</members>  
  143.         <members>ContentVersion</members>  
  144.         <members>Contract</members>  
  145.         <members>ContractContactRole</members>  
  146.         <members>ContractLineItem</members>  
  147.         <members>DuplicateRecordItem</members>  
  148.         <members>DuplicateRecordSet</members>  
  149.         <members>EmailMessage</members>  
  150.         <members>Entitlement</members>  
  151.         <members>EntitlementContact</members>  
  152.         <members>EntityMilestone</members>  
  153.         <members>Event</members>  
  154.         <members>ExchangeUserMapping</members>  
  155.         <members>FeedItem</members>  
  156.         <members>ForecastingAdjustment</members>  
  157.         <members>ForecastingCategoryMapping</members>  
  158.         <members>ForecastingOwnerAdjustment</members>  
  159.         <members>ForecastingQuota</members>  
  160.         <members>ForecastingTypeToCategory</members>  
  161.         <members>Idea</members>  
  162.         <members>Indicator_Badge__mdt</members>  
  163.         <members>Lead</members>  
  164.         <members>LeadGen_Reroute_Parent_Queue__mdt</members>  
  165.         <members>Macro</members>  
  166.         <members>MacroAction</members>  
  167.         <members>MacroInstruction</members>  
  168.         <members>Opportunity</members>  
  169.         <members>OpportunityCompetitor</members>  
  170.         <members>OpportunityContactRole</members>  
  171.         <members>OpportunityLineItem</members>  
  172.         <members>Order</members>  
  173.         <members>OrderItem</members>  
  174.         <members>PartnerRole</members>  
  175.         <members>PersonAccount</members>  
  176.         <members>Pricebook2</members>  
  177.         <members>PricebookEntry</members>  
  178.         <members>Product2</members>  
  179.         <members>ProfileSkill</members>  
  180.         <members>ProfileSkillEndorsement</members>  
  181.         <members>ProfileSkillUser</members>  
  182.         <members>QuickText</members>  
  183.         <members>Quote</members>  
  184.         <members>QuoteLineItem</members>  
  185.         <members>RecordAction</members>  
  186.         <members>RequestsForAccessSIQ</members>  
  187.         <members>Scorecard</members>  
  188.         <members>ScorecardAssociation</members>  
  189.         <members>ScorecardMetric</members>  
  190.         <members>ServiceContract</members>  
  191.         <members>Site</members>  
  192.         <members>SocialPersona</members>  
  193.         <members>Solution</members>  
  194.         <members>StreamActivityAccess</members>  
  195.         <members>StreamingChannel</members>  
  196.         <members>Task</members>  
  197.         <members>Topic</members>  
  198.         <members>TopicAssignment</members>  
  199.         <members>User</members>  
  200.         <members>WorkBadge</members>  
  201.         <members>WorkBadgeDefinition</members>  
  202.         <members>WorkOrder</members>  
  203.         <members>WorkOrderLineItem</members>  
  204.         <members>WorkThanks</members>  
  205.         <members>*</members>  
  206.         <name>CustomObject</name>  
  207.     </types>  
  208.     <types>  
  209.         <members>*</members>  
  210.         <name>Letterhead</name>  
  211.     </types>  
  212.     <types>  
  213.         <members>*</members>  
  214.         <name>CustomObjectTranslation</name>  
  215.     </types>  
  216.     <types>  
  217.         <members>*</members>  
  218.         <name>PermissionSet</name>  
  219.     </types>  
  220.     <types>  
  221.         <members>*</members>  
  222.         <name>PostTemplate</name>  
  223.     </types>  
  224.     <types>  
  225.         <members>*</members>  
  226.         <name>Profile</name>  
  227.     </types>  
  228.     <types>  
  229.         <members>*</members>  
  230.         <name>Queue</name>  
  231.     </types>  
  232.     <types>  
  233.         <members>*</members>  
  234.         <name>QuickAction</name>  
  235.     </types>  
  236.     <types>  
  237.         <members>*</members>  
  238.         <name>RemoteSiteSetting</name>  
  239.     </types>  
  240.     <types>  
  241.         <members>*</members>  
  242.         <name>ReportType</name>  
  243.     </types>  
  244.     <types>  
  245.         <members>*</members>  
  246.         <name>Workflow</name>  
  247.     </types>  
  248.     <types>  
  249.         <members>*</members>  
  250.         <name>Report</name>  
  251.     </types>  
  252.     <types>  
  253.         <members>*</members>  
  254.         <name>SiteDotCom</name>  
  255.     </types>  
  256.     <types>  
  257.         <members>*</members>  
  258.         <name>CustomSite</name>  
  259.     </types>  
  260.     <types>  
  261.         <members>*</members>  
  262.         <name>Scontrol</name>  
  263.     </types>  
  264.     <types>  
  265.         <members>*</members>  
  266.         <name>Settings</name>  
  267.     </types>  
  268.     <types>  
  269.         <members>*</members>  
  270.         <name>CustomTab</name>  
  271.     </types>  
  272.     <types>  
  273.         <members>*</members>  
  274.         <name>Translations</name>  
  275.     </types>  
  276.     <types>  
  277.         <members>*</members>  
  278.         <name>CustomPageWebLink</name>  
  279.     </types>  
  280.     <types>  
  281.         <members>*</members>  
  282.         <name>Role</name>  
  283.     </types>  
  284.     <types>  
  285.         <members>*</members>  
  286.         <name>SamlSsoConfig</name>  
  287.     </types>  
  288.     <version>44.0</version>  
  289. </Package>  

Reports, documents, email templates, etc are foldered and currently not supported.