Validation rule for the Probability field in Opportunity

Sample:

For Probability equal to 0, Probability = 0
For Probability equal to 10, Probability = 0.10
For Probability equal to 20, Probability = 0.20
For Probability equal to 30, Probability = 0.30
For Probability equal to 40, Probability = 0.40
For Probability equal to 50, Probability = 0.50
For Probability equal to 60, Probability = 0.60
For Probability equal to 70, Probability = 0.70
For Probability equal to 80, Probability = 0.80
For Probability equal to 90, Probability = 0.90
For Probability equal to 100, Probability = 1.00

Validation rule to avoid closing an Opportunity other than today in Salesforce

Validation Rule:


AND ( 
CloseDate <> TODAY(), 
OR ( 
ISCHANGED( StageName ) , 
DATEVALUE( CreatedDate ) = TODAY() 
), 
Probability = 1.00//you can use isClosed = true also 
)

Schema Builder in Salesforce


Schema Builder provides a dynamic environment to add new custom objects, custom fields, and relationships to your schema. This eliminates the need to click from page to page to find the details of a master-detail relationship or to add a new custom field to an object in your schema. For example, if you’re using Schema Builder to view the details of your schema, you can add a new custom object without leaving Schema Builder. The drag-and-drop interface lets you easily add a custom object or new field, and saves the layout of your schema any time you move an object.

Schema Builder provides details such as the field values, required fields, and how objects are related by displaying lookup and master-detail relationships. You can view the details for both standard and custom objects in Schema Builder.

Schema Builder is enabled by default and lets you add the following to your schema:
  1. Custom objects
  2. Lookup relationships
  3. Master-detail relationships
  4. Fields of the following types:
  5. Auto Number
  6. Formula
  7. Roll-up Summary
  8. Checkbox
  9. Currency
  10. Date
  11. Date/Time
  12. Email
  13. Number
  14. Percent
  15. Phone
  16. Picklist
  17. Picklist (Multi-Select)
  18. Text
  19. Text (Encrypted)
  20. Text Area
  21. Long Text Area
  22. Rich Text Area
  23. URL
1. Go to Setup --> Schema Builder.


2. Drag and drop Object.


3. Save the object with details.


4. Add a field by drag and drop.


5. Save the field.


Output:



Freeze Button in Salesforce User detail Page

Freeze button prevent users from logging into your organization.

Note: Freezing user accounts doesn't frees the user licenses available for use in your organization.

User permission needed: Manage Users.

Freeze:



Unfreeze:



How to export a report as an Excel file?

1. Open the Report.

2. Click "Export Details".


3. Click "Export".


4. Click "Save".


5. Click "Done".


Work.com Tutorial

Use the below link for Work.com Tutorial


Cheers!!!

Recognition in Work.com in Salesforce

Available in: Enterprise, Performance, and Unlimited Editions.

Recogniton requires a license to Work.com Motivate, Align or Work.com Perform, which are available as add-on licenses for Enterprise Edition or Unlimited Edition and is included in Performance Edition.

Cheers!!!

Work.com in Salesforce

Salesforce Work.com is a sales performance management platform that takes human resources into the future. Focusing on the social elements of goal alignment, employee motivation, and performance management, Salesforce Work.com takes goal-setting, feedback, recognition, and continuous dialogue into the cloud—no more clunky human resources software. Salesforce Work.com seamlessly integrates our social performance management into the applications where your sales, service, and marketing teams work each and every day, aligning employee goals with the company’s mission and objectives. Performance management has never been more engaging, effective, and simple—empowering managers and their employees alike to work better.

Setting up Work.com:

1. Go to Setup --> Build --> Customize --> Work.com --> Settings.

2. Enable the Thanks Settings.

3. Click "Save" button.


4. Go to any record's feed.

5. Click "Thanks".


6. Select the user.

7. Select the badge.

8. Enter the message.

9. Click Share.


Output:


Annotations in Apex in Salesforce.com

An Apex annotation modifies the way a method or class is used, similar to annotations in Java.

Annotations are defined with an initial @ symbol, followed by the appropriate keyword. To add an annotation to a method, specify it immediately before the method or class definition.

Apex supports the following annotations:

1. @Deprecated
2. @Future
3. @IsTest
4. @ReadOnly
5. @RemoteAction
6. @TestVisible

Apex REST annotations:

1. @RestResource(urlMapping='/yourUrl')
2. @HttpDelete
3. @HttpGet
4. @HttpPatch
5. @HttpPost
6. @HttpPut

@future annotation in Salesforce:
     Use the future annotation to identify methods that are executed asynchronously. When you specify future, the method executes when Salesforce has available resources.

     For example, you can use the future annotation when making an asynchronous Web service callout to an external service. Without the annotation, the Web service callout is made from the same thread that is executing the Apex code, and no additional processing can occur until the callout is complete (synchronous processing).

Note:
     1. Methods with the future annotation must be static methods and can only return a void type.
     2. The specified parameters must be primitive data types, arrays of primitive data types, or collections of primitive data types.
     3. Methods with the future annotation cannot take sObjects or objects as arguments.

Cheers!!!

Limits in Custom Settings in Salesforce


Limits in Custom Settings:

1. The total amount of cached data allowed for your organization is the lesser of these two values:

    i.  10 MB
    ii. 1 MB multiplied by the number of full-featured user licenses in your organization

2. Each Certified managed package gets its own separate limit in addition to your organization limit.

3. 300 fields per custom setting.

4. You can’t share a custom setting object or record.

5. No owner is assigned when a custom setting is created, so the owner can’t be changed.

6. Custom settings are a type of custom object. Each custom setting counts against the total number of custom objects available for your organization.

Project Archive in Force.com IDE

Project Archive in Force.com IDE is used to get a backup of destination environment before deployment begins. This Archive can be used for future reference and can be used for reverting back the changes done earlier.

A deployment archive (archive of destination environment) is not generated if the deployment plan only contains deletes.


Cheers!!!

Web Services in Salesforce

Different APIs supported by Salesforce.com are

REST API
Accessing objects in your organization using REST.
SOAP API
Integrating your organization’s data with other applications using SOAP.
Chatter REST API
Accessing Chatter feeds and social data such as users, groups, followers, and files using REST.
Bulk API
Loading or deleting large numbers of records.
Metadata API
Managing customizations in your organization and building tools that can manage the metadata model, not the data itself.
Streaming API
Providing a stream of data reflecting data changes in your organization.
Apex REST API
Building your own REST API in Apex. ExposesApex classes as RESTful Web services.
Apex SOAP API
Creating custom SOAP Web services in Apex. Exposes Apex classes as SOAP Web services.
Tooling API
Building custom development tools forForce.com applications.

APIs act as Web services interface for interacting with Salesforce.

REST API

REST API is mainly used for  ease of integration and development. It supports smaller sets of data.

SOAP API

SOAP API cab be written in any language that supports Web services.
For example, you can use SOAP API to integrate Salesforce with your organization’s ERP and finance systems, deliver real-time sales and support information to company portals, and populate critical business systems with customer information.

Chatter REST API

Chatter REST API provides programmatic access to Chatter feeds and social data such as users, groups, followers, and files.

Bulk API

Bulk API is based on REST principles and is optimized for loading or deleting large sets of data.
Bulk API is designed to process data from a few thousand to millions of records.
The easiest way to use Bulk API is to enable it for processing records in Data Loader using CSV files. This avoids the need to write your own client application.

Use Metadata API

Use Metadata API to retrieve, deploy, create, update, or delete customizations for your organization. The most common use is to migrate changes from a sandbox or testing organization to your production environment. Metadata API is intended for managing customizations and for building tools that can manage the metadata model, not the data itself.
The easiest way to access the functionality in Metadata API is to use the Force.com IDE or Force.com Migration Tool.

Streaming API

Use Streaming API to receive notifications for changes to data that match a SOQL query that you define.
Streaming API is useful when you want notifications to be pushed from the server to the client. Consider Streaming API for applications that poll frequently. Applications that have constant polling action against the Salesforce infrastructure, consuming unnecessary API call and processing time, would benefit from this API which reduces the number of requests that return no data.Streaming API is also ideal for applications that require general notification of data changes. This enables you to reduce the number of API calls and improve performance.

Apex REST API

Use Apex REST API when you want to expose your Apex classes and methods so that external applications can access your code through REST architecture. Apex REST API supports both OAuth 2.0 and Session ID for authorization.

Apex SOAP API

Use Apex SOAP API when you want to expose your Apex methods as SOAP Web service APIs so that external applications can access your code through SOAP. Apex SOAP API supports both OAuth 2.0 and Session ID for authorization.

Tooling API

Use Tooling API when you want to manage and deploy working copies of Apex classes and triggers and Visualforce pages and components, set checkpoints or heap dump markers, execute anonymous Apex, and access logging and code coverage information.

Apex Scheduler Limits

Sa1lesforce.com has set some limits on Apex Scheduler. Below are the limits in Apex Scheduler in Salesforce.com.

1. You can only have 100 scheduled Apex jobs at one time(Maximum number of Apex classes scheduled concurrently).

2. The maximum number of scheduled Apex executions per a 24-hour period is 250,000 or the number of user licenses in your organization multiplied by 200, whichever is greater. The licenses that count toward this limit are full Salesforce user licenses or Force.com App Subscription user licenses. Chatter Free, Chatter customer users, Customer Portal User, and partner portal User licenses aren't included.

Cheers!!!

How to save a web page as a PDF file?

Google Chrome can be used to save a web page as a PDF file.

We can easily get our train ticket as a PDF file using Google Chrome.

1. Click "Print".


2. Click "Change".


3. Select "Save As PDF".


4. Click "Save".

What is CRM Tool?

Customer Relationship Management is a bridge between an Organization and its customer. CRM tool is a piece of software that helps to build this bridge.

CRM tool helps to manage Sales, Service and Marketing modules in typical CRM system. CRM tool automates all the CRM processes.

Below are the advantages of using CRM tool
  1.  Improve your business processes
  2. Automates CRM processes
  3. Win new clients and contracts
  4. Increase profitably
  5. Decrease customer management costs
Some top CRM tools in market are
  1. Salesforce.com CRM
  2. Zoho CRM
  3. Siebel CRM
  4. Chordiant CRM
  5. Oracle CRM
  6. Microsoft Dyanamics CRM
  7. Sophos CRM

Cheers!!!

How to remove time from date in Visualforce page?


Sample Code:

Visualforce page:

<apex:page controller="Sample" >
    <apex:form >        
         <apex:outputText value="{0,date,dd'/'MM'/'yyyy}" >
             <apex:param value="{!temp}"/>
         </apex:outputText>
    </apex:form>
</apex:page>
 


Apex Controller:

public with Sharing class Sample
{   
    public Date gettemp()
    {
        Date d = date.ValueOf('2013-12-10');
        return d;
    }
    public List<Member__c> mem {get;set;}   
      
    public sample()
    {
    }
}


Output:


How to populate field values in Standard Page Layout in Salesforce?

Scenario:

The relationship between Member and Blog objects is Lookup. Member is parent and Blog is child.

When "New Blog" button is clicked from Blog related list in Member Detail page, the Blog owner field in Blog record should be auto populated from Member Name.

See the below steps for solution

To find object URL:


To find the Id of the inputText:



Visualforce page:

<apex:page standardController="Blog__c" extensions="NewBlogOverriddenExt" action="{!onLoad}>

</apex:page>

Apex Class:


public class NewBlogOverriddenExt {
    Blog__c blog = new Blog__c();
    Id memberId;
    public NewBlogOverriddenExt(ApexPages.StandardController controller) {
        blog = (Blog__c)controller.getRecord();
        memberId = blog.Member__c;
    }
    public PageReference onLoad() {
        Member__c member = [SELECT Name FROM Member__c WHERE ID = : memberId];
        PageReference pg = new PageReference('/a03/e?');
        pg.getParameters().put('00NU0000003SVOs',member.Name);
        pg.getParameters().put('nooverride','1');// Important to avoid recursion
        return pg;
    }
}

Override New button in Blog object:






Output:





Cheers!!!

Uploading CRM Content from Local Drive using Apex in Salesforce

1. Click Libraries Tab and create a new Library.


2. Create a Visualforce page.

<apex:page standardController="Member__c" extensions="UploadContentController">
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection >
            <apex:panelGrid columns="2">
                Select File :
                <apex:inputFile fileName="{!contentToUpload.PathOnClient}" value="{!fileContent}"/>
            </apex:panelGrid>
        </apex:pageBlockSection>
        <apex:pageBlockButtons location="bottom">
            <apex:commandButton value="Upload" action="{!uploadContents}"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:form>
</apex:page> 

3. Create a Controller.

public class UploadContentController {
    public ContentVersion contentToUpload {get;set;}
    Id memberId;
    public Blob fileContent {get;set;}
    public UploadContentController(ApexPages.StandardController controller) {
        memberId = controller.getId();
        contentToUpload = new ContentVersion();
    }
    public PageReference uploadContents() {
        List<ContentWorkSpace> CWList = [SELECT Id, Name From ContentWorkspace WHERE Name = 'Member Files'];
        contentToUpload.VersionData = fileContent;
        insert contentToUpload;
        
        contentToUpload = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :contentToUpload.Id];
        
        ContentWorkspaceDoc cwd = new ContentWorkspaceDoc();
        cwd.ContentDocumentId = contentToUpload.ContentDocumentId;
        cwd.ContentWorkspaceId = CWList.get(0).Id;
        insert cwd;
        
        PageReference pg = new PageReference('/' + memberId);
        pg.setRedirect(true);
        return pg;
    }
}

4. Create a button for the object.


5. Add the Button to the page layout.

6. Click the "Upload Content" button from a record.


7. Select a file and click "Upload" button.


8. Add "Related Content" related list.

9. Click "Search All" button in "Related Content" related list.


10. Click "Attach" to attach the file to the related content.

11. Click "Back" to go back to the record.


Output:



Cheers!!!

Salesforce Communities Vs Portals

Salesforce Communities is the only community platform that combines the power of social networking with business processes for breakthrough collaboration and productivity.

In Salesforce Communities,

  1. We can integrate Knowledgebase, Chatter Answers, etc...
  2. We can easily collaborate with Partners, Leads, Customers, etc...
  3. We can share dashboards with customers.
  4. For internal users, no need of separate username and password(SSO).
  5. Maximum customization(design using Site.com is also supported) is allowed.
  6. We can use Chatter.
  7. We can promote social collaboration for sales, service and marketing business processes.

Feed Tracking in Salesforce

Using Feed Tracking, users can see updates for records they follow in their Chatter feed.We can track only up to 20 fields per object.

The following standard field types can't be tracked:
  • Auto-number, formula, and roll-up summary fields
  • Encrypted and read-only system fields
  • The Expected Revenue field on opportunities
  • The Solution Title and Solution Details fields on solutions
It won't show modified values and old values for Multi-Picklist and Long Textarea  fields.
  1. History tracking shows the following:
  2. Prior value - old value.
  3. Current value - value.
  4. Who has done the changes - person who modified it.
  5. When it was changed - date and time of modification.
1. Go to Setup --> Build --> Customize --> Chatter --> Feed Tracking.



2. Enable Feed Tracking, select the fields and click "Save" button.


Output:



CreatedById is null in trigger issue - workaround

CreatedById will be populated in a record only after insert operation.

Before insert, the CreatedById will be null.

In the is case, we can use UserInfo.getUserId() which returns the current User Id.

Check the below link for sample code


Cheers!!!

How to get current User Id using Apex in Salesforce?

UserInfo.getUserId() - returns the current User Id

Sample Code:

User Usr = new User();


Usr = [SELECT Phone, Id FROM User WHERE Id = : UserInfo.getUserId()];

the above code will return the current user's Phone and Id who execute this code.

Cheers!!!

Developer Settings in Salesforce


Selenium IDE

Selenium IDE is a Firefox plugin which records and plays back user interactions with the browser. Use this to either create simple scripts or assist in exploratory testing. It can also export Remote Control or WebDriver scripts, though they tend to be somewhat brittle and should be overhauled into some sort of Page Object-y structure for any kind of resiliency.

Features:

1. Allows you to easily and quickly record and play back tests in the actual environment that they will run.

2. You can choose to use its recording capability, or you may edit your scripts by hand.

3. Autocomplete support.

4. Able to move commands around quickly.

Cheers!!!

How to convert time zone in Salesforce?

format(String, String) is used to change the time zone.

Sample Code:

Visualforce page:

<apex:page controller="Sample">
Current Date in US : {!USDateTime}

<br/>

Current Date in UK : {!UKDateTime}
</apex:page>

Apex Controller:

public class Sample { 
    public String USDateTime {get;set;}
    public String UKDateTime {get;set;}    
    public Sample() {
        DateTime temp = System.now();
        USDateTime = temp.format('MM/dd/yyyy HH:mm:ss', 'America/New_York');
        UKDateTime = temp.format('MM/dd/yyyy HH:mm:ss', 'London');        
    } 
}

Output:



How to convert US to UK time zone in Salesforce?

format(String, String) is used to change the time zone.

Sample Code:

Visualforce page:

<apex:page controller="Sample">
Current Date in US : {!USDateTime}

<br/>

Current Date in UK : {!UKDateTime}
</apex:page>

Apex Controller:

public class Sample {
    public String USDateTime {get;set;}
    public String UKDateTime {get;set;}  
    public Sample() {
        DateTime temp = System.now();
        USDateTime = temp.format('MM/dd/yyyy HH:mm:ss', 'America/New_York');
        UKDateTime = temp.format('MM/dd/yyyy HH:mm:ss', 'London');      
    }
}

Output:



How to set Managed Package in Developer Edition in Salesforce?

1. Go to Setup --> App Setup --> Create --> Packages.

2. Click "Edit" button.


3. Click "Continue" button.


4. Give a Namespace Prefix and click "Review my Selections" button.


5. Click "Save" button.


Cheers

System.ListException: Before Insert or Upsert list must not have two identically equal elements - Workaround

This exception occurs when you are trying to insert or upsert a list which is having two or more identical records. In this case we have to use set instead of list. So, that it will be overwritten because list can contain duplicates but set cannot contain duplicates.

Check this to know more about List, Set, Map.

http://www.infallibletechie.com/2012/07/list-set-and-map-in-salesforce.html

Cheers!!!

Validation Rule and Trigger is not working during Lead conversion - Solution

To fire Validation Rule and Trigger during Lead conversion, follow the below steps

1. Go to Setup --> Build --> Customize --> Leads --> Settings and check "Enforce Validation and Triggers from Lead Convert" check box.



Rules for naming variables

  1. Variable name should be Unique within scope
  2. Variable name should be <= 255 characters (based on the programming language)
  3. Variable name should not contain spaces or any special characters (. , “ - $ # * and others). The underscore _ is a valid character
  4. Variable name cannot be a reserved word
  5. Should use upper and lower case with purpose
  6. It is always good programming practice to use names that are descriptive or mnemonic
  7. The first character of the variable name must either be alphabet or underscore
  8. It should not start with the digit
Example:

Integer i = 0;
String EmployeeName = 'Arul';

How to fetch all record types in Salesforce?

SOQL:

SELECT Id, Name, DeveloperName, SobjectType FROM RecordType

Object name is RecordType.

Apex:

List<RecordType> RTList = [SELECT Id, Name, DeveloperName, SobjectType FROM RecordType];


How to get record id from standard controller using Apex in Salesforce?

Sample Code:

Visualforce page:

<apex:page standardcontroller="account" extensions="Sample">
{!Aid}
</apex:page>


Apex Controller:

public class Sample {

    public Id Aid {get;set;}
   
    public Sample(ApexPages.StandardController controller) {
        Account acc = new Account();
        Aid = controller.getId();
    }        
}


Output in Account Page layout:


How to set Currency format in apex:outputText?

Sample Code:

Visualforce page:

<apex:page controller="Sample">
<apex:outputLabel value="The value is : "/>
<apex:outputText value="{0, number, currency}">
    <apex:param value="{!inte}"/>
</apex:outputText>
</apex:page>



Apex Controller:

public class Sample { 
    public Decimal inte {get;set;}
    public Sample() {
        inte = 098.23;
    }         
}


Output:


Sample Code:

Visualforce page:

<apex:page extensions="Sample" standardController="Employee__c">
<apex:pageBlock >
    <apex:pageBlockSection columns="1">
        <apex:outputText value="${0, number, ###,###,###,##0.00}">
            <apex:param value="{!a}" />
        </apex:outputText>
        <apex:outputText value="${0, number, ###,###,###,##0.00}">
            <apex:param value="{!b}" />
        </apex:outputText>
        <apex:outputText value="${0, number, ###,###,###,##0.00}">
            <apex:param value="{!c}" />
        </apex:outputText>
    </apex:pageBlockSection>
</apex:pageBlock>

</apex:page>

Apex Class:

public class Sample {
    public Decimal a {get;set;}
    public Decimal b {get;set;}
    public Decimal c {get;set;}
    
    public Sample(ApexPages.StandardController controller) {
        a = 1800.00;
        b = 200;
        c = 34567.09;
    }

}

Output:



Unable to fetch reference records in Workbench - Workaround

By default, in Workbench "Allows SOQL Parent Relationship Queries" will be unchecked. So, check the "Allows SOQL Parent Relationship Queries" check box to  fetch reference records in Workbench.

1. Go to "Settings".


2. Check "Allows SOQL Parent Relationship Queries" check box.


3. Click "Apply Settings".

Output: