Cannot add a master-detail relationship child to a custom junction object

Custom junction objects can't have detail objects. That is, a custom junction object can't become the master object in a multilevel master-detail relationship.

This is a limitation from Salesforce.

Check this for more information

How to display maps on standard address fields in Salesforce?

1. Go to Maps and Location Settings.

2. Enable Maps and Location Services.

When you enable autocomplete on standard addresses, Salesforce app users can enter text on standard address fields and see possible matching addresses in a picklist.


How to transfer tasks back to Lead after conversion in Salesforce?

Make sure the users have "View and Edit Converted Leads" permission.

Check this for more information on this permission.

Sample Code:


  1. trigger LeadTrigger on Lead ( after update ) {  
  3.     Map < Id, Id > mapOpptyIdLeadId = new Map < Id, Id >();  
  5.     for ( Lead objLead :  ) {  
  6.         /* 
  7.             Once the Lead is converted, getting the Converted Opportunity Id 
  8.         */  
  9.         if ( String.isNotBlank( objLead.ConvertedOpportunityId ) && String.isBlank( trigger.oldMap.get( objLead.Id ).ConvertedOpportunityId ) )          
  10.             mapOpptyIdLeadId.put( objLead.ConvertedOpportunityId, objLead.Id );  
  12.     }  
  14.     if ( mapOpptyIdLeadId.size() > 0 ) {  
  16.         /* 
  17.             Calling the Queueable interface to transfer the tasks 
  18.         */  
  19.         System.enqueueJob( new TransferActivities( mapOpptyIdLeadId ) );  
  21.     }  
  23. }  

Queueable Interface:

  1. public class TransferActivities implements Queueable {  
  3.     Map < Id, Id > mapOpptyIdLeadId = new Map < Id, Id >();  
  5.     public TransferActivities( Map < Id, Id > mapOpptyIdLeadId ) {  
  7.         this.mapOpptyIdLeadId = mapOpptyIdLeadId;  
  9.     }  
  11.     public void execute( QueueableContext qc ) {  
  13.         List < Task > listTasks = [ SELECT Id, WhatId, WhoId FROM Task WHERE WhatId IN: mapOpptyIdLeadId.keySet() ];  
  15.         for ( Task objTask : listTasks ) {  
  17.             system.debug( 'Lead Id is ' + mapOpptyIdLeadId.get( objTask.WhatId ) );  
  18.             objTask.WhoId = mapOpptyIdLeadId.get( objTask.WhatId );  
  19.             /* 
  20.                 Setting WhatId to null since Task cannot be linked to Lead and Opportunity 
  21.             */  
  22.             objTask.WhatId = null;  
  24.         }  
  26.         update listTasks;  
  28.     }  
  30. }  

How to avoid Auto Activation of Sandbox in Salesforce?

Auto Activate should be disabled while refreshing to avoid auto activation of sandbox. The old sandbox will be available until we click Activate button after the refresh.

Activating a refreshed sandbox replaces the current sandbox with the refreshed version and permanently deletes the older version and all data in it. Your production org and its data aren’t affected.

Click Discard to discard a refreshed sandbox. This action is displayed only for sandboxes that aren’t activated. You can discard a sandbox if you don’t want to use it or if you plan to do another refresh.

How to get all the fields in a Field Set in Salesforce?

Sample Field Set:

Sample Code:

  1. for ( Schema.FieldSetMember f :  SObjectType.Employee__c.FieldSets.Test.getFields() ) {  
  3.     system.debug( f.getFieldPath() );  
  5. }  

Here Employee__c is a Custom Object and Test is the field set name.


How Account Name and Contact name are populated in Salesforce using Web to Case?

The contact name will be populated automatically if Contact is Existing with the "Web Email" into Salesforce otherwise it will be blank. If you wanted to populate the contact that is not existing then you have to do some customization using apex trigger.
Web to case should populate the contact field IF the email address already exists and it only exists once.

Make sure that the Web Name, Web Company, Web Phone and Web Email fields are on the Case pagelayout. These fields are what captures the Web-to-Case fields. Web-to-Case Name field is the Web Name field in your Org(Your Salesforce instance), Web-to-Case Phone is your Web Phone field in your Org, etc.

What happens is that if the information provided by the Web-to-Case form filler matches Account and Contact information in your Org the Contact Name and Account Name fields on your Case pagelayout will populate with the correct information. 

How to run Data Loader CLI command from Command Prompt?

Navigate to Data Loader's bin folder to execute the command. Make sure the path information is accurate.

Account Name Auto Completion in Salesforce

Displays US-based companies in the Account Name field as sales reps enter information. Reps can select a suggested company from the list, making it easier to create new business accounts.

1. Go to Account Settings.

2. Select Enable Automated Account Fields.

3. Create an Account to test it.

Custom Lightning Component Vs. Visualforce Page

Visualforce page

Visualforce app development is familiar to anyone who has built web apps. Developers create Visualforce pages by composing components, HTML, and optional styling elements. Visualforce can integrate with any standard web technology or JavaScript framework to allow for a more animated and rich user interface. Each page is accessible by a unique URL. When someone accesses a page the server performs any data processing required by the page, renders the page into HTML, and returns the results to the browser for display.

Benefits of Visualforce:

User-friendly development
Developers can edit their Visualforce markup in the same window that displays the resulting page. Consequently, developers can instantly verify the result of an edit just by saving their code. The Visualforce editor pane also includes auto-completion and syntax highlighting.
Visualforce also supports “quick fixes” that allow developers to create supporting components on the fly. For example, a developer can define a new Visualforce page simply by logging in to Salesforce and then entering the name of the new page in a URL. Much like a wiki, if the page does not yet exist, the platform creates it for you.

Integration with other Web-based user interface technologies
Because Visualforce markup is ultimately rendered into HTML, designers can use Visualforce tags alongside standard HTML, JavaScript, Flash, or any other code that can execute within an HTML page on the platform, including Lightning platform merge fields and expressions.

Model-View-Controller (MVC) style development
Visualforce conforms to the Model-View-Controller (MVC) development pattern by providing a clear division between the view of an application (the user interface, defined by Visualforce markup), and the controller that determines how the application works (the business logic, defined by a Visualforce controller written in Apex). With this architecture, designers and developers can easily split up the work that goes with building a new application—designers can focus on the look and feel of the user interface, while developers can work on the business logic that drives the app.

Concise syntax
Visualforce pages can implement the same functionality as s-controls but with approximately 90% fewer lines of code.

Data-driven defaults
Visualforce components are rendered intelligently by the platform. For example, rather than forcing page designers to use different component tags for different types of editable fields (such as email addresses or calendar dates), designers can simply use a generic <apex:inputField> tag for all fields. The Visualforce renderer displays the appropriate edit interface for each field.

Automatically upgradeable
Visualforce pages do not need to be rewritten when other parts of the Lightning platform are upgraded. Because the pages are stored as metadata, they are automatically upgraded with the rest of the system.

Make Long-Running Callouts from a Visualforce Page 
Use asynchronous callouts to make long-running requests from a Visualforce page to an external Web service and process responses in callback methods. Asynchronous callouts that are made from a Visualforce page don’t count toward the Apex limit of 10 synchronous requests that last longer than five seconds. As a result, you can make more long-running callouts and you can integrate your Visualforce pages with complex back-end assets.

Disadvantages of Visualforce:

View State Size
The view state size of your Visualforce pages must be under 135 KB.

Load Times
Large page sizes directly affects load times.
Higher latency, which degrades mobile performance.
Poor match for low-end or older mobiles devices with limited compute resources.
Visualforce processes markup tags on the Salesforce server, which can increase the response time.

Multiple Concurrent Requests
Concurrent requests are long-running tasks that could block other pending tasks.

Preventing Field Values from Dropping Off the Page
If your page contains many fields, including large text area fields, and has master-detail relationships with other entities, it may not display all data due to limits on the size of data returned to Visualforce pages and batch limits. The page displays this warning: “You requested too many fields to display. Consider removing some to prevent field values from being dropped from the display.”

Not Mobile friendly
Making VF mobile friendly makes the development complex.

Standard tabs, custom object tabs, and list views that are overridden with a Visualforce page aren’t supported in the Salesforce app. Mobile users see the default Salesforce page for the object instead.

Limited interactivity (aside from JavaScript functionality you add yourself).
Difficult to create an immersive user experience.

Lightning Component 

Lightning Components is a UI framework for developing web apps for mobile and desktop devices. It’s a modern framework for building single-page applications with dynamic, responsive user interfaces for Lightning Platform apps. It uses JavaScript on the client side and Apex on the server side.

Benefits of Lightning Component:
Load Times
Lightning Component processes markup tags on the client(browser), which can decrease the response time.

Rich component ecosystem
Create business-ready components and make them available in the Salesforce app, Lightning Experience, and Communities. Salesforce app users access your components via the navigation menu. Customize Lightning Experience or Communities using drag-and-drop components on a Lightning Page in the Lightning App Builder or using Community Builder. Additional components are available for your org in the AppExchange. Similarly, you can publish your components and share them with other users.

Uses a stateful client and stateless server architecture that relies on JavaScript on the client side to manage UI component metadata and application data. The client calls the server only when absolutely necessary; for example to get more metadata or data. The server only sends data that is needed by the user to maximize efficiency. The framework uses JSON to exchange data between the server and the client. It intelligently utilizes your server, browser, devices, and network so you can focus on the logic and interactions of your apps.

Event-driven architecture
Uses an event-driven architecture for better decoupling between components. Any component can subscribe to an application event, or to a component event they can see.

Faster development
Empowers teams to work faster with out-of-the-box components that function seamlessly with desktop and mobile devices. Building an app with components facilitates parallel design, improving overall development efficiency.
Components are encapsulated and their internals stay private, while their public shape is visible to consumers of the component. This strong separation gives component authors freedom to change the internal implementation details and insulates component consumers from those changes.

Device-aware and cross browser compatibility
Apps use responsive design and provide an enjoyable user experience. The Lightning Component framework supports the latest in browser technology such as HTML5, CSS3, and touch events. Salesforce promoting this as next platform for building web and mobile apps and will work with mobile.

Components have a object oriented approach and can inherit other components. The advantages are widely known but ultimately it makes for more organized, reusable and manageable components.

Another big win for Salesforce is the enhanced security that comes with Lightning. LockerService, for instance, is a security feature that isolates Lightning components (the building blocks of Lightning pages) so they can’t interact with each other. This helps safeguard against malicious input.

Disadvantages of Lightning Component Framework

1. Since Lightning components are new, there are still some features that aren’t supported.
2. Doesn't work well with Internet Explorer browser.

Final Touch point

1. There are no major disadvantages of Lightning Components
2. Enhanced security that comes with Lightning
3. Lightning component development time is much less than Visualforce
4. Reusability is higher in Lightning Components
5. For long running callouts Visualforce with Continuation Server is the best approach

How to Bypass all triggers, validation rules, process builders and workflow rules in Salesforce?

Hierarchical Custom Settings can be used to bypass all triggers, validation rules, process builders and workflow rules.

Custom Settings to Bypass:

Bypass in Validation Rules:

Bypass in Workflow Rules:

Bypass in Trigger:

Bypass in Process Builder:

Custom Settings record to Bypass:

After setting the data in custom settings for user Test as above, it will bypass Validation Rules, Workflow Rules, Triggers, and Process Builders.

How to query Geolocation field in Salesforce?

If Geo_Location__c is the API name of the field, then Geo_Location__Latitude__s, Geo_Location__Longitude__s will be the fields to be used in the SOQL.

Sample Query:

Collapsible Pane in Lightning Component Salesforce

Sample Code:


  1. <aura:component implements="force:appHostable">  
  3.     <aura:attribute name="activeSections" type="List" default="['a']" />  
  4.     <aura:attribute name="activeSectionsMessage" type="String" default="" />  
  6.     <div class="slds-box slds-theme_default">   
  8.         <p>{! v.activeSectionsMessage }</p>  
  10.         <lightning:accordion allowMultipleSectionsOpen="true"  
  11.                              onsectiontoggle="{! c.handleSectionToggle }"  
  12.                              activeSectionName="{! v.activeSections }">  
  14.             <lightning:accordionSection name="a" label="Section A">  
  16.                 <aura:set attribute="body">  
  18.                     This is section A.  
  20.                 </aura:set>  
  22.             </lightning:accordionSection>  
  24.             <lightning:accordionSection name="b" label="Section B">  
  26.                     This is section B.  
  28.             </lightning:accordionSection>  
  30.             <lightning:accordionSection name="c" label="Section C">  
  32.                     This is section C.  
  34.             </lightning:accordionSection>  
  36.         </lightning:accordion>  
  38.     </div>  
  40. </aura:component>  

Component Controller:

  1. ({  
  3.     handleSectionToggle: function ( cmp, event ) {  
  5.         var openSections = event.getParam('openSections');  
  7.         if ( openSections.length === 0 )   
  8.             cmp.set('v.activeSectionsMessage'"All sections are closed");  
  9.         else   
  10.             cmp.set('v.activeSectionsMessage'"Open sections: " + openSections.join(', '));          
  12.     }  
  14. })  


All Sections Open:

All Sections Closed: