How to create New Component in MavensMate?

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


Cheers!!!

How to Refresh From Server in MavensMate?

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


Cheers!!!

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.


Cheers!!!

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".


Cheers!!!

Run Package Control: Install Package command in Sublime Text

1. Go to Tools --> Command Palette.


2. Search "Package Control: Install Package"


Cheers!!!

MavensMate Force.com IDE installation for for Windows

1. Go to "http://www.sublimetext.com/3".

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 "https://packagecontrol.io/installation".

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.


Note:

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".


Cheers!!!

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.


Cheers!!!

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

http://developer.force.com/cookbook/recipe/trigger-pattern-for-tidy-streamlined-bulkified-triggers

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
execute(handler);
}
private static void execute(ITrigger handler) {
// Before Trigger
if(Trigger.isBefore) {
handler.bulkBefore();
}
else {
handler.bulkAfter();
}
}

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) {
TriggerFactory.createHandler(Opportunity.sObjectType);
}

Cheers!!!

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

http://slingfive.com/pages/code/scriptconverter/

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

Note:

This site works only in Internet Explorer Browser.

Cheers!!!

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.

Cheers!!!

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.

Cheers!!!

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.


Output:


The users who can manually share records are

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

Note:

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

Cheers!!!

@ReadOnly annotation in Salesforce

The @ReadOnly annotation allows you to perform unrestricted queries against the Force.com 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.

Only WebService, RemoteAction, or Schedulable.execute() methods can be marked read-only.

For more information, check the below link

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_ReadOnly.htm

Cheers!!!

Salesforce Interview questions with answers Part 30

1. Life cycle of  Salesforce ?
http://www.infallibletechie.com/2015/11/life-cycle-of-salesforce.html

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?
http://www.infallibletechie.com/2013/03/how-to-create-many-to-many-relationship.html

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, Force.com 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?
No.

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?
http://www.infallibletechie.com/2013/05/record-types-in-salesforce.html

14. What are permission sets?
http://www.infallibletechie.com/2012/11/what-are-permission-sets-and-how-do.html

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?
http://www.infallibletechie.com/2012/11/sharing-rules.html

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?
http://www.infallibletechie.com/2014/02/difference-between-queue-and-public.html

20. Difference between roles, permission sets and profiles
http://www.infallibletechie.com/2012/12/difference-between-roles-and-profiles.html

21. Define master-detail & lookup relationship
http://www.infallibletechie.com/2013/02/difference-between-lookup-and-master.html

Cheers!!!

Life Cycle of Salesforce

1. Plan

2. Analyze

3. Design

4. Build

5. Validate

6. Deploy

Cheers!!!

Campaign Influence in Salesforce

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.


Cheers!!!

How to know the picklist replace status in Salesforce?

To know about Picklist replace option, check the below link

http://www.infallibletechie.com/2013/03/what-is-use-of-replace-in-picklist-in.html

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.



Note:
You will receive an email too.

Cheers!!!

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);

Cheers!!!

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);
            pg.setRedirect(true);
            return pg;
        } catch(DMLException e) {
            return null;
        }
    }
}

Test Class:

@isTest
private class LeadCreationTest {
    @isTest static void leadTest() {
        LeadCreation obj = new LeadCreation();
        try {
            obj.newLead();
        } catch(DMLException e) {
            system.assertEquals(e.getMessage(), e.getMessage());
        }
        obj.lastName = 'Testing';
        obj.newLead();
    }
}

Note:

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

Cheers!!!

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.


Cheers!!!

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('http://www.infallibletechie.com');
        pg.setRedirect(true);
        return pg;
    }
}

Test class:

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

Cheers!!!

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:pageBlockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>

Apex Controller:

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

Output:


Cheers!!!