How to create New Component in MavensMate?

Go to MavensMate --> Metadata to create New Component in MavensMate.


How to Refresh From Server in MavensMate?

Right click the project and select MavensMate --> Refresh From Server to Refresh From Server in MavensMate.


How to install Install MavensMate API(mm) version?

Go to MavesMate --> MavensMate API(mm) --> Install MavensMate API(mm) version to install Install MavensMate API(mm) version.


How to create a new project using MavensMate?

1. Create a new project by navigating to MavensMate --> New Project.

2. Enter your credentials and click "Create Project".


Run Package Control: Install Package command in Sublime Text

1. Go to Tools --> Command Palette.

2. Search "Package Control: Install Package"


MavensMate IDE installation for for Windows

1. Go to "".

2. Select your OS.

3. Go to the downloaded file folder location.

4. Execute it and install it.

5. Open the Sublime Text 3 app after installation.

6. Go to View --> Show Console.

7. Go to "".

8. Copy the code from there.

9. Paste it in the Sublime Text console and press Enter button..

10. Close and open the Sublime Text 3 again.

11. Go to Command Palette.

12. Search "Package Control: Install Package".

13. Search and select "MavensMate".

14. Go to MavensMate --> Settings --> User.

15. Set mm_workspace variable.

I have set as D:\\MavensMate Workspace, since I created a folder "MavensMate Workspace" in D drive. This is the location where our local source code resides.

16. Go to MavensMate --> MavensMate API(mm) --> Install MavensMate API(mm) version.


Click Install MavensMate API(mm) version even if it is disabled.

17. Restart Sublime Text.

18. Create a new project by navigating to MavensMate --> New Project.

19. Enter your credentials and click "Create Project".


How to filter today's Time-Based Workflow in Salesforce?

1. Go to Time-Based Workflow.

2. Set the condition as created date equals TODAY.


Trigger factory implementation in Salesforce

These patterns provide an elegant way of coding triggers to avoid bad practices such as repetitive SOQL queries that can hit governor limits and multiple triggers over the same object. The patterns enforce a logical sequence to the trigger code and in turn help to keep code tidy and more maintainable. Keeping trigger logic for each object in a single place avoids problems where multiple triggers are in contention with each other and makes it easier to debug. Enforcing up front caching of data within a trigger keeps the trigger 'bulkified' and avoids those nasty 'too many SOQL queries'.

Use the below link for Trigger factory implementation in Salesforce

Sample Trigger pattern for Opportunity Object:

ITrigger Interface:
public interface ITrigger {
void bulkBefore();
void bulkAfter();

OpportunityTriggerHandler Apex Class:
public with sharing class OpportunityTriggerHandler implements ITrigger {
public OpportunityTriggerHandler() {

public void bulkBefore() {
if(trigger.isInsert) {
//Here we will call before insert actions
} else if(trigger.isUpdate) {
//Here we will call before update actions
} else if(trigger.isDelete) {
//Here we will call before delete actions
} else if(trigger.isUndelete) {
//Here we will call before undelete actions

public void bulkAfter() {
if(trigger.isInsert) {
//Here we will call after insert actions
} else if(trigger.isUpdate) {
//Here we will call after update actions
} else if(trigger.isDelete) {
//Here we will call after delete actions
} else if(trigger.isUndelete) {
//Here we will call after undelete actions

TriggerFactory Apex Class:
public with sharing class TriggerFactory {
public static void createHandler(Schema.sObjectType soType) {
ITrigger handler = getHandler(soType);

if(handler == null) {
throw new TriggerException('No Trigger Handler registered for Object Type: ' + soType);

// Execute the handler to fulfil the trigger
private static void execute(ITrigger handler) {
// Before Trigger
if(Trigger.isBefore) {
else {

private static ITrigger getHandler(Schema.sObjectType soType) {
if(soType == Opportunity.sObjectType) {
return new OpportunityTriggerHandler();

return null;

Opportunity Trigger:
trigger AccountTrigger on Opportunity(after delete, after insert, after update, before delete, before insert, before update) {


How to convert VB Script to JAVASCRIPT?

VB script works on in Internet Explorer Browser.

VB script works only up to IE 6 version. So, in order to convert your VB Script to JAVASCRIPT, use the below Online Tool

This tool is easy to use. Try it!!!


This site works only in Internet Explorer Browser.


Automation server can't create object issue

In order to fix Automation server can't create object issue, follow the below steps

1. Go to Internet Options.

2. Select Security tab.

3. Select Trusted Sites.

4. Click "Sites" button.

5. Enter your site address in which you are facing this issue and click "Add" button.

6. Click "Custom Level" button.

7. Enable "Initialize and script ActiveX controls not marked as safe for scripting" option and click "Ok".

8. Click "Ok" again and test it.


How to test Batch Class's execute method alone in Salesforce?

Sample Code:

sObject__c sObj = [SELECT Id, FROM sObject__c WHERE your_condition];
Database.BatchableContext bc;
BatchClass obj = new BatchClass();
obj.execute(bc, new List<sObject__c> {sObj});

Similarly you can test start and finish methods too.


Sharing Button in Salesforce

Manual sharing allows users to grant one-off access to their individual records for users, roles, and public groups.

Manual sharing is available:
  1. To the record owners, their managers in the role hierarchy, and administrators.
  2. For objects set as public read-only or private in organization-wide defaults.
1. Click "Sharing" button.

2. Click "Add" button.

 3. Select the users and access.


The users who can manually share records are

1. Record Owner.
2. Administrator.
3. User above the role of the Record Owner's role.


You cannot manually share a contact which not linked to an account.


@ReadOnly annotation in Salesforce

The @ReadOnly annotation allows you to perform unrestricted queries against the database. All other limits still apply. It's important to note that this annotation, while removing the limit of the number of returned rows for a request, blocks you from performing the following operations within the request: DML operations, calls to System.schedule, calls to methods annotated with @future, and sending emails.
A Visualforce page cannot hold more than 1000 records. But, @readOnly annotation increases this limit to 10,000. 

Only WebService, RemoteAction, or Schedulable.execute() methods can be marked read-only.
Using Apex, the Total number of records that can be retrieved by SOQL queries is 50,000. It is used to increase the SOQL limit from 50k to million.

Salesforce Interview questions with answers Part 30

1. Life cycle of  Salesforce ?

2. Can we convert Master Detail converts lookup ? and vice versa and how ?
Yes. By using Change Data Type button.

3. How do u create Many to Many relationship?

4. What happens if a junction object is deleted?
Many to many relationship will be lost. Both the objects will be independent.

5. Have u done  Deployment ?
Yes. ANT tool, IDE and Change Set.

6. How do you Transfer Reports from one org to org?
Through deployment.

7. Reports From production to sandbox?
Through deployment and through sandbox refresh.

8. Where we use contracts?
Entitlement Management.

9. Does Validation rule run on delete?

10. Field Description – long text , edited the description , Today – a  , tomorrow – b , Day after  tomorrow – c ,  ( Track all the changes )
Feed Tracking can be used.

11. What does Test/Design Documents include and how you prepare them
From the requirement.

12. Types of workflow
Email Alert, Task, Field Update, Outbound Message.

13. Why we use record type in reports?

14. What are permission sets?

15. How do we assign permission sets?
Go the user record and in the Permission Set Assignment related list, we can assign.

16. Types of reports
Tabular, Summary, Matrix and Joined

17. What is sharing rules?

18. If two users bare the same position in a org how one can access the others records in his absence.
By default they cannot see. Using Team, it can be shared.

19. What is queues?

20. Difference between roles, permission sets and profiles

21. Define master-detail & lookup relationship


Life Cycle of Salesforce

1. Plan

2. Analyze

3. Design

4. Build

5. Validate

6. Deploy


Campaign Influence in Salesforce

Permission to create Campaign in Salesforce
Marketing User check box on the user detail is required to create Campaigns.
Marketing Users can view, create, edit, and delete Campaigns as long as they have the “Read,” “Create,” “Edit,” and “Delete” permissions for Campaigns in the Profile.
Users that don't have the Marketing User checkbox selected only have access to view Campaigns and advanced Campaign setup, edit the Campaign History for a single lead or contact, and run Campaign reports if they have the “Read” permission for Campaigns.

Campaign Influence in Salesforce is used to associate multiple influential campaigns to a single opportunity.

View influential campaigns from the Campaign Influence related list on the opportunity detail page. The Primary Campaign Source field on an opportunity detail page allows you to designate the most influential campaign for that opportunity.

1. Go to Customize --> Campaigns --> Campaign Influence.

2. Save the Campaign Influence.

3. You can add campaigns to Opportunities using Campaign Influence related list.

How to know the picklist replace status in Salesforce?

To know about Picklist replace option, check the below link

To know the status, check the below

1. Once you replace, you will be able to see a screen as below.

2. Click Backgound Jobs Page link to view the status.

You will receive an email too.


How to use Query inside Query in SOQL?

Sample SOQL:

List<Account> listAccount = [SELECT Id, Name FROM Account WHERE Id IN (SELECT AccountId FROM Opportunity)];

system.debug('Output is ' + listAccount);


How to write code for try catch in test class in Salesforce?

Sample Class:

public class LeadCreation {
    public Lead objLead;
    public String lastName;
    public LeadCreation() {
    public PageReference newLead() {
        objLead = new Lead(Company = 'Test', LastName = lastName, Status = 'Open - Not Contacted');
        try {
            insert objLead;
            PageReference pg = new PageReference('/' + objLead.Id);
            return pg;
        } catch(DMLException e) {
            return null;

Test Class:

private class LeadCreationTest {

    @isTest static void leadTest() {
        LeadCreation obj = new LeadCreation();
        try {
        } catch(DMLException e) {
            system.assert(e.getMessage().contains('Last Name'));
        obj.lastName = 'Testing';



This code is written in a way to just cover catch block.

Lead with Inactive Owners Report in Salesforce

1. Go to Report Types.

2. Create a new Lead Report Type.

3. Save the Custom Lead Report Type.

4. Click "Edit Layout".

5. Select "Add fields related via lookup".

6. Select Lead Owner.

7. Select Active field and save.

8. Create a Report with the custom report type created now.

9. Add Active equal to false in the report criteria.


How to cover PageReference method in test class in Salesforce?

Sample Apex Class:

public class Sample {
    public Sample() {
    public PageReference goToInfallible() {
        PageReference pg = new PageReference('');
        return pg;

Test class:

private class SampleTest {
    @isTest static void test() {
        Sample s = new Sample();


Custom Metadata Types

Custom metadata is customizable, deployable, packageable, and upgradeable application metadata. First, you create a custom metadata type, which defines the form of the application metadata. Then you build reusable functionality that determines the behavior based on metadata of that type. Similar to a custom object or custom setting, a custom metadata type has a list of custom fields that represent aspects of the metadata. After you create a public custom metadata type, you or others can declaratively create custom metadata records that are defined by that type. When you package a public custom metadata type, customers who install the package can add their own records to the metadata type. Your reusable functionality reads your custom metadata and uses it to produce customized application behavior.

Custom metadata rows resemble custom object rows in structure. You create, edit, and delete custom metadata rows in the Metadata API or in Setup. Because the records are metadata, you can migrate them using packages or Metadata API tools. Custom metadata records are read-only in Apex and in the Enterprise and Partner APIs.

Custom Metadata Types are similar to Custom Settings. Let's see an example to use it in Salesforce.

1. Go to Custom Metadata Types.

2. Click "New Custom Metadata Type".

3. Save Custom Metadata Type.

4. Click "New" in Custom Fields section.

5. I have created a Field with API name Name__c.

6. Click Manage to create records.

7. Click "New" to create records.

8. Save a test record.

9. To see the records in a VF page use the below code

Visualforce page:

<apex:page controller="Sample">
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockTable value="{!listEmpSettings}" var="e">
            <apex:column value="{!e.DeveloperName}"/>
            <apex:column value="{!e.Name__c}"/>

Apex Controller:

public class Sample {
    public List<Employee_Setting__mdt> listEmpSettings {get;set;}
    public Sample() {
        listEmpSettings = [SELECT DeveloperName, Name__c FROM Employee_Setting__mdt];