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!!!