Frequently asked Salesforce Interview questions with answers - Part 3

1) How to overcome recursive Trigger?
Recursive trigger can be handled by using Boolean variable in class. Example:

Class:

public class example{
      public static boolean firstRun = true;
}

Trigger:

trigger recursiveTriggerExample on TestObj__c (before Insert){
      if(p.firstRun){
             p.firstRun = false;
             <perform your task>
      }
}

2) What can workflow do, which Trigger can't?
We can schedule workflow on desired time but Trigger can't be scheduled.

3) Difference between Process Builder and Trigger?

Process Builder: Something which evaluates criteria and perform actions when criteria is met.

Trigger
: Apex code based evaluation of criteria to set chain of events.

4) Can we delete records using Process builder?

There is no action available in process builder to delete records. However, we can delete records using Apex method.

To call an Apex Method, add a call apex method to your process and select an Apex class with a @invocable method annotation.

5) Write a Trigger to populate number of contacts in Account?
Check answer at: http://anupkabra.blogspot.in/2017/08/trigger-to-update-total-number-of.html

6) How to call Visualforce page using custom command button?
By using below Javascript:

window.location = 'apex/visualforcePageName' 
  1. Create a command button on the object from setup. 
  2. Click on edit and enter Label and Name as you want 
  3. Display Type should be "Detail Page Button" 
  4. Behavior should be "Execute Javascript" 
  5. Content Source should be "OnClick JavaScript" 
  6. In the blank body, enter the above JavaScript.
7) What is Sale Process?
A Sale process is used to determine which opportunity stages are selectable when record types are enabled. In other words,it determines what stage is the opportunity and based on that, what action can be taken.

8) What is a difference between Role and Profile?
Role:
  1. Determines what is visible to the User
  2. It is not mandatory to have Role.
Profile:
  1. Determines what actions Users are allowed to perform.
  2. It is mandatory to have profile.
9) What is Viewstate and how to avoid viewstate error?
Viewstate is a state of visualforce page which helps salesforce to regenerate the page when it comes back from server.

Viewstate stores following data:
  1. All non-transient data members in the associated controller (either standard or custom) and the controller extensions.
  2. Objects that are reachable from a non-transient data member in a controller or controller extension.
  3. The component tree for that page, which represents the page's component structure and the associated state, which are the values applied to those components.
  4. A small amount of data for Visualforce to do housekeeping.
Avoiding viewstate error:
  1. Minimize number or forms on page.
  2. Declare variable as Transient to reduce viewstate.
  3. Use custom objects or custom settings to store large read only data.
  4. Refine SOQL to retrieve only the data needed by page.
10) Limitation of Viewstate?
Visualforce imposes a limit of 135K on viewstate.

11) Can we perform DML activities in constructor?
No. We can perform DML activities in constructor.

12) How will you create a new record in Account when a command button is clicked in Custom object using VF page (without UI)
  1. Create a class which will have a function to insert records in new object
  2. Call that function in visualforce <apex:page> tag.
  3. Call visualforce page using command button (refer question 6)
Example:

Visualforce Page:

<apex:page controller="DMLStatementOnPageloadController" action="{!createAccount}">
</apex:page>

Class:
public with sharing class DMLStatementOnPageloadController {

    public PageReference createAccount(){
        Account acc = new Account(name = 'DMLStatementOnPageload');
        insert acc ;
        return null;
    }
}

13) Approval step is already created and it is active now. I want to add one more step. How do I do it?
We can't make any changes once the approval process is active. We need to create a new approval process.

14) Scenario where recursive workflow can occur.

Lets assume an object Test__c has three fields Field1__c, Field2__c and Field3__c. Whenever, any field is updated, workflow will get triggered which will update a field, Field1__c. Since a field is updated, again a workflow will get triggered and it in this way workflow will keep on executing.

15) What is @future and what parameters can be passed to it?

A future method runs in the background, asynchronously. You can call a future method for executing long-running operations, such as callouts to external Web services or any operation you’d like to run in its own thread, on its own time. You can also make use of future methods to isolate DML operations on different sObject types to prevent the mixed DML error.
The specified parameters must be primitive data types, arrays of primitive data types, or collections of primitive data types.

16) Can we call @future in Triggers?
Yes, we can call, Create Apex Handler class and create a future mathod. Same method you can call from trigger.

17) Explain Schedule Apex

The Apex Scheduler lets you delay execution so that you can run Apex classes at a specified time. This is ideal for daily or weekly maintenance tasks using Batch Apex. To take advantage of the scheduler, write an Apex class that implements the Schedulable interface, and then schedule it for execution on a specific schedule.

Syntax:
global class SomeClass implements Schedulable {
    global void execute(SchedulableContext ctx) {
        // Write your code here
    }
}


18) What is permission set?

We all know that a single profile can be given to more than one person. In case, one of the user needs a special permission to view some object. If we make changes in the profile, it will be available to everyone who are associated with that profile. Therefore, we create a permission set which is like an additional access given to particular user without changing the profile.

19) Explain different types of Reports available in salesforce.

There are four types of Reports available in salesforce:

Tabular Reports:Tabular reports are the simplest and fastest way to look at your data. Similar to a spreadsheet, they consist simply of an ordered set of fields in columns, with each matching record listed in a row. While easy to set up, they can't be used to create groups of data and there are limits to how you can use them in dashboards. Consequently, they're often best used for tasks like generating a mailing list.

Summary Reports: Summary reports are similar to tabular reports, but also allow users to group rows of data, view subtotals, and create charts. These will take you a bit more time to set up, but summary reports give us many more options for organizing the data, and are great for use in dashboards.

Matrix Reports: Matrix reports allow you to group records both by row and by column. These reports are the most time-consuming to set up, but they also provide the most detailed view of our data. Like summary reports, matrix reports can have graphs and be used in dashboards

Joined Reports:Joined reports let you create different views of data from multiple report types. In a joined report, data is organized in blocks. Each block acts like a “sub-report,” with its own fields, columns, sorting, and filtering. You can add a chart to a joined report.  

20) Explain OWD.

Org-wide defaults(OWD) specify the baseline level of access that the most restricted user should have. Use org-wide defaults to lock down your data, and then use the other record-level security and sharing tools (role hierarchies, sharing rules, and manual sharing) to open up the data to users who need it.


Part 1 : Salesforce Interview Questions
Part 2 : Salesforce Interview Questions

Cheers !
Facebook - anupkabravlogs
Instagram - anupkabravlogs
YouTube   - Anup Kabra Vlogs

Comments

  1. Why don't you make a separate blog for salesforce alone. We love the way you elaborate functionalities in salesforce. See you in LinkedIn.

    ReplyDelete
  2. Thanks for sharing this interview questions admin, really helpful. I have bookmarked this page for my future reference. Keep up the good work and share more.
    Salesforce Course in Chennai | Salesforce Training in Chennai

    ReplyDelete
  3. Hello,
    I m Really looking forward to read more. Your site is very helpful for us .. This is one of the awesome post i got the best information through your site and Visit also this site
    best camera phone under 20000
    Really many thanks

    ReplyDelete
  4. hi,
    latest interview questions and other competitive exams and so on ... . we represent the video also.
    salesforce interview
    salesforce interview questions
    saleforce questions

    ReplyDelete
  5. I Have Read Your Post This is very nice and informative blog . Thank you for sharing such like of information.
    Salesforce Administrator Training

    ReplyDelete
  6. Very Nice Blog
    Visit us for - Supercharge your field staff training with Noticeboard. From field sales to logistics teams, Noticeboard is the platform of choice for all training needs of frontline teams.

    Get your team started today on one of the leading field staff training platforms.

    ReplyDelete

Post a Comment