Tuesday, 31 July 2012

Apex Data Loader

* Data Loader is a client application for the bulk import or export of data. (Up to 5 million records)
* Use it to insert, update, delete, or export Salesforce records.
* When importing data, Data Loader reads, extracts, and loads data from comma separated values (CSV) files or from a database connection.
* When exporting data, it outputs CSV files.
Note: If commas are not appropriate for our locale, use a tab or other delimiter.

We can use Data Loader in two different ways:

User interface—When we use the user interface, we work interactively to specify the configuration parameters, CSV files used for import and export, and the field mappings that map the field names in your import file with the field names in Salesforce.

Command line—When you use the command line, you specify the configuration, data sources, mappings, and actions in files. This enables you to set up Data Loader for automated processing.

Data Loader offers the following key features:
• An easy-to-use wizard interface for interactive use
• An alternate command line interface for automated batch operations
• Support for large files with up to 5 million records
• Drag-and-drop field mapping
• Support for all objects, including custom objects
• Can be used to process data in both Salesforce and Database.com
• Detailed success and error log files in CSV format
• A built-in CSV file viewer
• Support for Windows 7

Use Data Loader when:
* You need to load 50,000 to 5 million records.
* Data Loader is supported for loads of up to 5 million records.
* If you need to load more than 5 million records, we recommend you work with a salesforce.com partner or visit the App Exchange for a suitable partner product.
* You need to load into an object that is not yet supported by the import wizards.
* You want to schedule regular data loads, such as nightly imports.
* You want to export your data for backup purposes.

Use the import wizards when:
• You are loading less than 50,000 records.
• The object you need to import is supported by import wizards.
* To see import wizards click Your Name > Setup > Data Management.
• You want to prevent duplicates by uploading records according to account name and site, contact email address, or lead email address.

Login Considerations
* If your organization restricts IP addresses, logins from untrusted IPs are blocked until they’re activated.
* Salesforce automatically sends you an activation email that you can use to log in. The email contains a security token that you must add to the end of your password.
* For example, if your password is mypassword, and your security token is XXXXXXXXXX, you must enter mypasswordXXXXXXXXXX to log in.

Configuring Data Loader
Use the Settings menu to change the default operation settings of Data Loader.
1. Start Data Loader by choosing Start > Programs > salesforce.com > Data Loader > Data Loader.
2. Choose Settings > Settings.
3. Edit the fields as desired:

Batch size
* In a single insert, update, upsert, or delete operation, records moving to or from Salesforce are processed in increments of this size.
*The maximum value is 200. We recommend a value between 50 and 100.
*The maximum value is 10,000 if the Use Bulk API option is selected.
Insert null values
*Select this option to insert blank mapped values as null values during data operations.
* Note that when you are updating records, this option instructs Data Loader to overwrite any existing data in mapped fields.
*This option is not available if the Use Bulk API option is selected.
*Empty field values are ignored when you update records using the Bulk API.
* To set a field value to null when the Use Bulk API option is selected, use a field value of #N/A.
Assignment rule
*Specify the ID of the assignment rule to use for inserts, updates, and upserts.
* This option applies to inserts, updates and upserts on cases and leads.
* It also applies to updates on accounts if your organization has territory assignment rules on accounts.
*The assignment rule overrides Owner values in your CSV file.
Server host
*Enter the URL of the Salesforce server with which you want to communicate.
* For example, if you are loading data into a sandbox, change the URL to
Specify how many seconds Data Loader waits to receive a response back from the server before returning an error for the request.
Query request size
*In a single export or query operation, records are returned from Salesforce in increments of this size.
*The maximum value is 2,000 records. Larger values may improve
performance but use more memory on the client.
Allow field truncation
*Select this option to truncate data in the following types of fields when loading that data into Salesforce: Email, Multi-select Picklist, Phone, Picklist, Text, and Text(Encrypted).
*This option is not available if the Use Bulk API option is selected. In that case, the load operation fails for the row if a value is specified that is too large for the field.

Use Bulk API
*Select this option to use the Bulk API to insert, update, upsert, delete, and hard delete records.
*The Bulk API is optimized to load or delete a large number of records asynchronously.
*It’s faster than the default SOAP-based  API due to parallel processing and fewer network round-trips.
*When you select the Hard Delete operation, the deleted records are not stored in the Recycle Bin.
*Instead, they become immediately eligible for deletion.
*The permission for this operation, “Bulk API Hard Delete,” is disabled by
default and must be enabled by an administrator.
*A Salesforce user license is required for hard delete.
Enable serial mode for Bulk API
*Select this option to use serial instead of parallel processing for Bulk API. *Processing in parallel can cause database contention. When this is severe, the load may fail.
* Using serial mode guarantees that batches are processed one at a time.  
* Note that using this option may significantly increase the processing time for a load.
*This option is only available if the Use Bulk API option is selected.
Upload Bulk API Batch as Zip File
*Select this option to use Bulk API to upload zip files containing binary attachments, such as Attachment records or Salesforce CRM Content.
*This option is only available if the Use Bulk API option is selected.
 To configure Data Loader to use the Bulk API for inserting, updating, upserting, deleting, and hard deleting records:
1. Start Data Loader by choosing Start > Programs > salesforce.com > Data Loader > Data Loader.
2. Choose Settings > Settings.
3. Select the Use Bulk API option.
4. Click OK.

Thursday, 26 July 2012

Process Visualizer in SFDC

- Fortunately, the Force.com platform has a Process Visualizer that renders each approval process
as a flowchart.

- The flowchart contains all of the critical details for each approval process, including the steps necessary for a record to be approved, the designated approvers for each step, the criteria used to trigger the approval process, and the actions that take place when a record is approved, rejected, recalled, or first submitted for approval.

Wednesday, 25 July 2012

The default workflow user in SFDC

The default workflow user is the user who should be assigned as the owner of a workflow action.

- If the user who originally triggered the rule is no longer active. If your organization uses
time-dependent actions in workflow rules, you must designate a default workflow user.

- Salesforce displays this username in the Created By field for tasks, the Sending User field for email,
and the Last Modified By field for field updates.

-  Salesforce does not display this username for outbound messages. If a problem occurs with a pending action, the default workflow user receives an email notification.

To set the default workflow user:

1. Click Your Name ➤ Setup ➤ Create ➤Workflow & Approvals ➤ Settings.

Note: If you click Activate without previously setting the default workflow user and
then click OK in the error dialog, you're sent directly to the Workflow & Approvals
Settings page.

2. Set the Default Workflow User field to any user in your organization. In most
cases, it's best to choose a system administrator.

3. Click Save.

* Workflow is built in business logic

Queues in SFDC


- Much like a collection of items in a lost and found drawer, a queue is a collection of records
that don't have an owner

- Users who have access to the queue can examine every record that's in it and claim ownership of the ones they want.

- Queues are traditionally used in sales and support organizations to distribute new leads and
support cases to the employees who have the most availability.
- Because the platform natively supports queues for Leads, Cases, and any custom object, we can create a queue for the Recruiting app's Position object.

Creating a Queue for Positions

- To define a queue, we simply need to know the types of records that can be placed in the queue
(in our case, Positions)
, and the users who are allowed to pull records out of it (in our case,
. Once we know those two things, defining the queue itself is just a matter of a few
simple clicks:

Note: As you can see, a single queue can handle multiple objects—the platform allows you to do this so that you don't have to define multiple queues for the same group of users. 

1. Click Your Name ➤ Setup ➤ Manage Users ➤ Queues.
2. Click New.
3. In the Queue Name text box, enter Unclaimed Positions Queue.
4. In the Queue Email text box, enter an email address for an individual or a
distribution list, such as recruiters@universalcontainers.com.
5. Select Send Email to Members.
6. In the Supported Objects section, move Position into the Selected Objects list.
7. In the Queue Members section, select Roles and Subordinates from the
Search drop-down list.

8. Move Role and Subordinates: Recruiting Manager to the Selected
Members list.
9. Click Save.

Tuesday, 24 July 2012

Manual Sharing Rule in SFDC

 "To share a particular record to a particular user or (Role or PG) we should use manual sharing"

Note: To make the Sharing Button visible on the detail page of the particular sObject record, we should go to the Page Layout of that particular object and there click on the buttons and make it available on the detail page of the record.

Defining a Manual Sharing Rule

* we need to share a particular candidate record that we own with another role, group, or user:

1. On the detail page for the candidate, click Sharing.

* Since we own this candidate record, we get to see details about who else can see the record
and why. If we didn't own this record, there would be a message about not having sufficient

Tip: If we wanted to view the names of each user who has access to the record rather
than just the names of the roles and public groups, we could click Expand List in this
page. Although the operation can take some time depending on the number of users
in our organization, it's helpful to determine whether we need to define a manual
sharing rule for a particular user or if he or she already has access.

2. Click Add.

3. In the Search drop-down list, choose whether we want to manually share the record
with a user, public group, role, or role and subordinates.

4. In the Currently Not Shared list, select the user, public group, or role that
should have access to the record, and click Add.

5. In the Access Level drop-down list, specify whether the user, public group, or
role should have read or read/write access to the record.

6. Click Save.

Organization Wide Defaults

Organization Wide Defaults in Our Recruiting App:

To determine the org-wide defaults that we'll need in our Recruiting app, we need to answer
the following questions for each object:
1. Who is the most restricted user of this object?
2. Is there ever going to be an instance of this object that this user shouldn't be allowed
to see?
3. Is there ever going to be an instance of this object that this user shouldn't be allowed
to edit?

Controlling Data with the Force.com Platform

Using the Import Wizard in SFDC

Understanding Entity Relationship Diagram (ERD) in SFDC

* > represents towards Parent Object.

Creating a Many-to-Many Relationship

- For our recruiting app, we're going to create a junction object called Job Posting.
- A job posting fits into the space between positions and employment websites
- one position can be posted many times, and one employment website can have many job postings.
- But a job posting always represents a posting about a single position on a single employment website. 
- In essence, the Job Posting object has a many-to-one relationship with both the Position and the Employment Website objects.
- And through those many-to-one relationships, we'll have a many-to-many relationship between the Position and Employment Website objects.

- In many apps, the sole purpose of a junction object is to simply relate two objects.
- So it often makes sense to give the junction object a name that indicates the association
or relationship it creates.
- For example, if you wanted to use a junction object to create a many-to-many relationship between bugs and cases, you could name the junction object BugCaseAssociation.

Using Cross-Object Formula Fields and Hyperlinks in formula of SFDC

( Job_Application__r.Candidate__r.Id ,
Job_Application__r.Candidate__r.Last_Name__c )

- Click the Insert Field button, and select Review >, Job Application >,Candidate >, Record ID, and click Insert.
- Salesforce generates a unique ID for every record.
- By inserting the record ID of the candidate in our HYPERLINK function, we're enabling our formula field to locate and link to the candidate's record.
- We are displaying first name and last name by using concatenation operator.
- Job_Application__r.Candidate__r.Id is the url and remaining is the data.

HYPERLINK(  Department__r.Id ,Department__r.Name__c & " " &  Department__r.Name  )
- To display Department name and ID at a time and create a link to the particular record

Multilevel Master-Detail Relationships

- We can create master-detail relationships with multiple levels.
- With multilevel master-detail relationships we can create reports that roll up data from all
levels of the data model.
- Trigger cascading deletes when a master record is deleted.

Adding fields to Search Layouts in SFDC

Default Available Search Layouts for a sObject:

Search Results: The search results that originate from searching in the left Sidebar
Search of the application or in Advanced Search.

Lookup dialogs: The lookup dialog results that originate from clicking the button
next to a lookup field on an edit page.

Tab: The list of recent records that appears on the home page of a tab, and
in related lists on other object detail pages.

Search Filter Fields: The filters that can be applied to search results.

Adding fields to Lookup dialog:

1. Go to detail page of the particular sObject, here I am going to candidates detail sObject page.

2. Click on Edit beside Lookup Dialogs shown above.

3. I added the fields to make those fields available while populating the lookup field at the edit page of the jobapplied sObject regarding to candidate record.

4. Apart form the standard field other fields also visible now by adding fields to the search list we can make the fields available.

5. I added fields apart from standard field for the tab home page using search Layout.

6. Like that for other Search Layouts also we can add additional fields to visible.

Using ISBLANK and ISPICKVAL in Formula fileds of salesforce.com

ISBLANK(Close_Date__c) &&

(ISPICKVAL(Status__c , "Closed - Filled") ||

ISPICKVAL(Status__c , "Closed - Not Approved"))

- ISBLANK(Close_Date__c) returns True if the Close_Date__c is blank

- ISPICKVAL(Status__c , "Closed - Filled") returns True if the Value of the Status__c pick list is  Closed - Filled

- TEXT(Status__c) = “Closed - Filled” {Same as above}, returns True if the Value of the Status__c pick list is  Closed - Filled

- && means both values should be True then only True.

- || means either one of the value is True then only True.

Using 'If' condition in formula field of SFDC

IF( ISBLANK( Close_Date__c ) , TODAY() - Open_Date__c, Close_Date__c - Open_Date__c )

- In the above formula field ISBLANK( Close_Date__c ) is the Condition.
- TODAY() - Open_Date__c will trigger if the condition is True.
- Close_Date__c - Open_Date__c will trigger if the condition is False.

Monday, 23 July 2012

Difference between salesforce.com and force.com

- Provides only basic CRM App's and standard objects.
- It is providing Application as a Service (SAAS).
- Which had build on Force.com Platform.
- It is like an application on Force.com platform.

- Provides Platform to develop VF pages and Apex Programming.
- It is three times lesser license cost when compared to salesforce.com.
- We can develop applications by using only force.com with three times lesser speed without using    salesforce.com.

- To Practice SFDC concepts we use developerforce.com which is free.

Actionfunction in VF

To return to a same page with empty fields in VF

public pageReference save() {
        pageReference  np = new pageReference ('/apex/temp3');
        return np;

Saturday, 21 July 2012

Ajax Partial Page Updates on VF page

In three ways we can do partial page updates:
* Implementing partial page updates with Command Links and Buttons using rerender attribute.
* Providing status for asynchronous operations that occur in background while a page user continues to work using <apex:actionstatus>.
*Applying ajax behavior to events on any component using <apex:actionsupport> tab.

Visual Force Important Points

* Custom controller executes entirely in system mode in which Object level, Field level permissions and sharing rules of the current user are ignored.
* Standard controller executes in user mode, in which permissions and sharing rules of the current user are enforced.
* Extending a standard controller allows you to build a Visual Force page that respects user permissions.
*Although the extension class executes in system mode, the standard controller executes in user mode.

*VF pages are compiled an rendered entirely by the Force.com platform.
* Dynamic VF components:
- <apex:datatable> in VF becomes Component.Apex.DataTable.
- <apex:outputtext> becomes,
   Component.Apex.OutputText otField = new Component.Apex.OutputText();
   otField.value='Some wild output text';
* JavaScript Remoting for Apex Controllers: To call apex methods to VF page, put @RemoteAction befor the apex methods.
*We cannot use the rerender attribute to update content in a table.
* It is not possible to create custom controller parametrized constructor
* You can't use data manipulation language (DML) operations in a “getxxx” method in a controller. For example, if your controller had a getName method, you could not use insert or update in the method to create an object.
* You can't use data manipulation language (DML) operations in a constructor method in a controller.
* You can't use the @future annotation in a “getxxx” or “setxxx” method in a controller, or in the constructor for a controller.

Thursday, 19 July 2012

Passing parameters between visualforce pages

Setting Parameters:
*From VF Page:
<apex:outputLink value="/apex/page4">click<apex:param name="EN" value="Success"/></apex:outputLink>
*From Page Reference:
PageReference nextpage = new PageReference('/apex/Page4?EN='+EmployeeName+'&EN2='+EmployeeName2);
-To pass more than one parameter We should use & symbol inbetween.
*  PageReference nextpage = new PageReference('/apex/Page4');
- We can use multiple put statements to pass multiple parameters.
To pass the parameters between the VF pages which have same controllers:
*No need to pass any parameters only the thing is that we should not  use nextpage.setRedirect(True);
*For this we need two VF pages and one controller.
 *VF page1:
<apex:page controller="customcontroller1">
<apex:form >
   Name<apex:inputtext id="inpEmployeeName" value="{!EmployeeName}"/><br/>
   <apex:CommandButton value="Next" action="{!next}" id="cmdNext" />

*VF page2:
<apex:page controller="customcontroller1">
   .The employee name is {!EmployeeName}

*APEX Controller1:
public class customcontroller1 {

    public PageReference next() {
        PageReference nextpage = new PageReference('/apex/Page2');
        nextpage.setRedirect(False);//By default it is false, we should not make it true

        //if we make it true values will be vanished while we are navigating from one 
        //page to another page
        return nextpage;      
    public String EmployeeName { get; set; }

To pass the parameters between the VF pages which have different controllers:
*For this we need two VF pages and two controllers.
*VF page1:
<apex:page controller="customcontroller1">
<apex:form >
   First<apex:inputtext id="inpEmployeeName" value="{!EmployeeName}"/><br/>
   Second<apex:inputtext id="inpEmployeeName2" value="{!EmployeeName2}"/><br/>
   Second<apex:inputtext id="inpEmployeeName3" value="{!EmployeeName3}"/><br/>
   <apex:CommandButton value="Next" action="{!next}" id="cmdNext" >     
  <!-- <apex:outputLink value="/apex/page4">click<apex:param name="EN" value="{!EmployeeName}"/></apex:outputLink>-->
*APEX Controller1:
public class customcontroller1 {

    public String EmployeeName3 { get; set; }

    public String EmployeeName2 { get; set; }

    public PageReference next() {
        //PageReference nextpage = new PageReference('/apex/Page4?EN='+EmployeeName+'&EN2='+EmployeeName2);
        PageReference nextpage = new PageReference('/apex/Page4');

        return nextpage.setRedirect(True); //Note that setRedirect method is used here

    public String EmployeeName { get; set; }

*VF page2:
 <apex:page controller="customcontroller2">
   The employee name is {!EmployeeName}<br/>
   The employee name is {!EmployeeName2}<br/>
   The employee name is {!EmployeeName3}
   <apex:detail subject="{!$CurrentPage.parameters.EN}"/>-->

*APEX Controller2:
public class customcontroller2 {

    public String EmployeeName { get; set; }
    public String EmployeeName2 { get; set; }
    public String EmployeeName3 { get; set; }
  public customcontroller4()
    EmployeeName = ApexPages.currentPage().getParameters().get('EN');
    EmployeeName2 = ApexPages.currentPage().getParameters().get('EN2');
    EmployeeName3 = ApexPages.currentPage().getParameters().get('EN3');


*Use 'assignedTo' in VF page instead of using 'ApexPages.CurrentPage().getParameters().get('name')'




Pick List in VF

Simple Pick List without using controller:
<apex:page >
<apex:form >
  <apex:selectList size="1">
      <apex:selectoption Itemlabel="India" Itemvalue="India"/>
      <apex:selectoption Itemlabel="India" Itemvalue="USA"/>
      <apex:selectoption Itemlabel="India" Itemvalue="UK"/>
Simple Pick List by using controller:

<apex:page controller="actionregionInterview">
<apex:form >
  <apex:selectList size="1">
      <apex:selectoptions value="{!items}"/>
public class actionregionInterview {   
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new selectoption('India', 'India'));
        options.add(new selectoption('Us', 'Us'));
        options.add(new selectoption('Australia', 'Australia'));
        return options;

    /*String[] Countries = new String[] {};
    public String[] getCountries() {
        return countries;
        public void setCountries(String[] countries) {
        this.countries = countries;


Monday, 16 July 2012

To display all the fields of sObject using Apex & VF

<apex:page showHeader="false" Controller="FieldsClass">
        <apex:DataTable value="{!data}" var="d">
             <apex:column headerValue="Field Name">
public class  FieldsClass {

     public map<string,Schema.SObjectField> data {get;set;}
     public  FieldsClass (){
         data = Schema.SObjectType.Book__c.fields.getMap();

Radio-buttons simple code

<apex:page controller="search">
<apex:form >
<apex:selectRadio value="{!searchCategory}" >
    <apex:selectOption itemValue="Member one" itemlabel="Member"/>
    <apex:selectOption itemValue="Blog" itemlabel="Blog"/>
    <apex:selectOption itemValue="Photo" itemlabel="Photo"/>
public class search {

    public String searchCategory { get; set; }

    // Constructor of the class
    public search()
    searchCategory = 'Member one';

Cascading Style Sheets

Inline Style:
<p style="color:blue;background-color:red;font-size:30px;font-family:verdana;margin-left:20px;text-align:center;">
Internal Style Sheet:
<style type="text/css">
body {background-color:yellow;}
p {color:blue;}
External Style sheet:
<link rel="stylesheet" type="text/css" href="mystyle.css" />
*save all the external style sheets with '.css' extension.
External Style sheet Example1:
<!DOCTYPE html>
<style type="text/css">
font-family:"Times New Roman";
<h1>CSS example!</h1>
<p>This is a paragraph.</p>
External Style sheet Example2:
The id and class Selectors
In addition to setting a style for a HTML element, CSS allows you to specify your own selectors called "id" and "class".

The id Selector
The id selector is used to specify a style for a single, unique element.
The id selector uses the id attribute of the HTML element, and is defined with a "#".
The style rule below will be applied to the element with id="para1":

 <!DOCTYPE html>
<style type="text/css">
<p id="para1">Hello World!</p>
<p>This paragraph is not affected by the style.</p>
Note: Do NOT start an ID name with a number! It will not work in Mozilla/Firefox.

The class Selector
The class selector is used to specify a style for a group of elements. Unlike the id selector, the class selector is most often used on several elements.
This allows you to set a particular style for many HTML elements with the same class.
The class selector uses the HTML class attribute, and is defined with a "."
In the example below, all HTML elements with class="center" will be center-aligned:
<!DOCTYPE html>
<style type="text/css">
<h1 class="center">Center-aligned heading</h1>
<p class="center">Center-aligned paragraph.</p>
You can also specify that only specific HTML elements should be affected by a class.
In the example below, all p elements with class="center" will be center-aligned:
<style type="text/css">
<h1 class="center">This heading will not be affected</h1>
<p class="center">This paragraph will be center-aligned.</p>

<!DOCTYPE html>
<style type="text/css">
<h1>CSS background-color example!</h1>
This is a text inside a div element.
<p>This paragraph has its own background color.</p>
We are still in the div element.