Export and Import in Salesforce

Export:
    Exporting (Getting) data from Salesforce.
    Select operation.

Import:
    Importing (Inserting) data into Salesforce.
    Insert, Update and Upsert operations.


Cheers!!!

Projects in Salesforce

Click the below link to get Salesforce Projects,
http://www.cloudspokes.com/challenges?category=Salesforce.com

Register, start coding and submit the code to earn money.

Good luck!


Cheers!!!

trigger.isInsert and trigger.isUpdate

trigger.isInsert is true when a new record is created and inserted.

trigger.isUpdate is true when an existing record is modified.

Example:


trigger memberInviteNotify on Member__c (after insert,after update)

{

        if(trigger.isInsert)

        {
        // When a new record is created and inserted, the flow will come here
        ............................
        ............................
        ............................ 
        }
        
        if(trigger.isUpdate)
        {

        // When an existing record is modified, the flow will come here

        ............................
        ............................
        ............................
        }

}


Cheers!!!

Example for SOSL(Salesforce Object Search Language)

Examples:

FIND {test*} 
IN ALL FIELDS 
RETURNING Account (Id, Name), Contact, Opportunity, Lead

Searches field values starting with the keyword 'test' in all fields in Account, Contact, Opportunity, Lead and displays the result.

FIND {Test} 
IN Name FIELDS 
RETURNING Lead(Name WHERE CreatedDate = THIS_FISCAL_QUARTER LIMIT 10)

Searches Test in Name field in Lead with the condition CreatedDate is this fiscal quarter.


Cheers!!!

SOSL - Salesforce Object Search Language

Unlike SOQL, which can only query one object at a time and multiple objects only if they are related to each other, SOSL enables you to search text, email, and phone fields for multiple objects simultaneously.

Use SOSL with the search() call to find records for one or more objects. The search() call searches most text fields on an object.

Cheers!!!

How to install Apex Data Loader?

Tto install Apex Data Loader, follow the below steps

1. Log into Salesforce.com
2. Go to Setup menu
3. Under Data Management go to Data Loader


4. Click 'Download the Data Loader' to download and install the Apex Data Loader


Cheers!!!

How to insert line break in email message using Apex in Salesforce?

To insert line break in email message using Apex in Salesforce, we have to use <br> tag. setHtmlBody() method is used here to send the email in HTML format.

Sample Trigger:

trigger memberInviteNotify on Member__c (after insert,after update)
{
    for(Member__c member:trigger.New)
    {
        String[] toAddresses = new String[] {member.E_Mail_Id__c};
        String messageBody;
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(toAddresses);
        
        //Email invitation
        if(trigger.isInsert)
        {
            mail.setSubject('Welcome to Sweet 16 Siebel Batch');
            messageBody = '<html><body>Hi ' + member.Name + ',Welcome to Sweet 16</body></html>';
            mail.setHtmlBody(messageBody);   
        }
        
        //Email notification
        if(trigger.isUpdate)
        {
            mail.setSubject('Updates in your details');

            //Message with line break tag
            messageBody = '<html><body>Hi ' + member.Name + ',Changes have been made to your details. <br><br>Contact administrator if you are not responisble.</body></html>';

            mail.setHtmlBody(messageBody);
        }
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
}

Cheers!!!

Contacting Salesforce

Please click the below link to get details about contacting Salesforce customer support

https://na12.salesforce.com/help/doc/en/salesforce_customer_support_cheatsheet.pdf


Cheers!!!

DEV 401 topics to concentrate

  • Security controls (also learn about criteria based sharing)
  • Profiles
  • object level permissions
  • Field level permissions
  • Record level permissions
  • Record level access
  • Role hierarchy
  • Reports
  • How are objects related to reports?
  • Type of dashboard to component to use per case scenarios
  • What can be done with custom report types?
  • Analytic Snapshots
  • Workflows
  • Parallel approval
  • Approval process
  • Use case for time triggered actions
  • Limitations of data loader on importing standard, custom objects
  • Features of the data loader
  • Sidebar feature how are items added
  • User objects


  • Types of relationships including hierarchal
  • Use case on best relationship to use
  • Use case for using Visualforce and Apex
  • Force.com Sites
  • Encrypted Fields
  • External ID fields
  • System Fields
  • Formula fields
  • Console
  • Page layouts & Mini page layouts
  • Record Ids
  • Process Visualizer
  • Multiple currencies

Enhanced List in Salesforce

Enhanced lists give you the ability to quickly view, customize, and edit list data to speed up your daily productivity.

<apex:enhancedList type="Member__c" rowsPerPage="10" height="500"/>
  1.  'rowsPerPage' attribute must be one of the following values: [10, 25, 50, 100, 200].
  2. 'height' attribute is mandatory.
  3. 'type' attribute is mandatory.

Cheers!!!

Pie chart using Apex in Salesforce

Visualforce Page:

<apex:page controller="Graph" >
<apex:chart height="250" width="350" data="{!pieData}"> 
<apex:pieSeries dataField="data" labelField="name"/> 
<apex:legend position="right"/> 
</apex:chart>
<apex:outputText value="{!temp1}"/>
</apex:page>

Apex:


public with sharing class Graph 
{  
public List<PieWedgeData> getPieData() 
{  
List<PieWedgeData> data = new List<PieWedgeData>();
List<Member__c> memb = new List<Member__c>();  

String sql = 'SELECT Name, Year_s_Of_Experience__c FROM Member__c';
memb = Database.Query(sql);
for(Member__c temp:memb)
{
data.add(new PieWedgeData(temp.Name,temp.Year_s_Of_Experience__c));
}
return data;  
}  

// Wrapper class  
public class PieWedgeData 
{  
public String name { get; set; }  
public Decimal data { get; set; }  

public PieWedgeData(String name, Decimal data) 
{  
this.name = name;  
this.data = data;  
}  
}  

Output:



How to find number of days between two dates using Apex?

Integer noOfDays = startDate.daysBetween(endDate);

The above formula is used to find number of days between two dates.


Cheers!!!

How to enable apex:chart

To enable <apex:chart>, Log a case in Salesforece.

To log a case, visit http://infallibletechie.blogspot.in/2012/07/how-to-log-case-in-developer-edition-in.html.

Cheers!!!

How to get Salesforce.com Organization ID?

To get Salesforce.com Organization ID, Go to Administration Setup --> Company Profile -->  Company Information -- > Salesforce.com Organization ID.



Cheers!!!

How to log a case in Developer edition in Salesforce?

To log a case in Developer edition in Salesforce,

1. Click 'Help'.

2. Click My 'Cases'.

3. Click 'Log a Case'.



4. Fill and click 'Submit' button.


Cheers!!!

How to display Dashboard in visualforce page in Salesforce?

<apex:page >
<apex:iframe src="https://na12.salesforce.com/01ZU0000000NHAt" scrolling="true" id="theIframe"/>
</apex:page>

Here src is the source of the Dashboard. See the below figure to get the Dashboard URL.



Cheers!!!

How to display radio buttons in vertical direction in Salesforce

To display checkbox options in vertical direction, layout property is used.

Example:

<apex:selectRadio value="{!searchCategory}" layout="pageDirection" >
    <apex:selectOption itemValue="Member__c" itemlabel="Member"/>
    <apex:selectOption itemValue="Blog__c" itemlabel="Blog"/>
    <apex:selectOption itemValue="Photo__c" itemlabel="Photo"/>
</apex:selectRadio>


Cheers!!!

How to get values from sObject dynamically in visualforce page?

Below is the simple example to get values from sObject in visualforce page.

Visualforce Page:

<apex:page controller="search">
<apex:form >

      <apex:pageBlock >
            <apex:pageBlockSection columns="2">
                  <apex:pageBlockSectionItem >
                        Enter the text to search
                  </apex:pageBlockSectionItem>
                  <apex:pageBlockSectionItem >
                        <apex:inputText value="{!searchKeyword}"/>
                  </apex:pageBlockSectionItem>
                  <apex:pageBlockSectionItem >
                        <apex:selectRadio value="{!searchCategory}" >
                              <apex:selectOption itemValue="Member__c" itemlabel="Member"/>
                              <apex:selectOption itemValue="Blog__c" itemlabel="Blog"/>
                              <apex:selectOption itemValue="Photo__c" itemlabel="Photo"/>
                        </apex:selectRadio>
                  </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                  <apex:commandButton value="Search" action="{!find}" reRender="result"/>
            </apex:pageBlockButtons>
      </apex:pageBlock>
     
      <apex:pageBlock id="result" >
      <apex:pageBlockTable value="{!result}" var="res">
                  <apex:repeat value="{!objectFields}" var="field">
                        <apex:column value="{!res[field]}"/>
                  </apex:repeat>
      </apex:pageBlockTable>       
      </apex:pageBlock>
     
</apex:form>
</apex:page>

Apex:


public class Search
{
      public String searchKeyWord {get;set;}
      public String searchCategory;
      public List<String> objectFields {get;set;}    
      public sObject sObjectToBind {get;set;}  
      public List<sObject> result {get;set;}
     
      public search()
      {
            searchCategory = 'Member__c';
      }
     
      public void find()
      {    
            /*    Getting fields for the sObject    */
        objectFields =  new List<String>();  
        Map<String , Schema.SObjectType> globalDescription = Schema.getGlobalDescribe();   
        Schema.sObjectType sObjType = globalDescription.get(searchCategory);             
        sObjectToBind = sObjType.newSObject();  
        Schema.DescribeSObjectResult r1 = sObjType.getDescribe();  
          
        Map<String , Schema.SObjectField> mapFieldList = r1.fields.getMap();  
        for(Schema.SObjectField field : mapFieldList.values())  
        {  
            Schema.DescribeFieldResult fieldResult = field.getDescribe();  
            if(fieldResult.isAccessible())  
            {  
                objectFields.add(fieldResult.getName());
            }  
        }  
       
        /*    Building Query with the fields    */
        Integer i = 0;
        String fieldsToFetch = '';
        for(String temp:objectFields)
        {       
            Integer len = objectFields.size();
            if(i==len-1)
            {
                  fieldsToFetch = fieldsToFetch + temp;
            }
            else
            {
                  fieldsToFetch = fieldsToFetch + temp + ',';
            }
            i++;
        }
            String sql = 'Select ' + fieldsToFetch + ' From ' + searchCategory + ' WHERE Name LIKE \'%' + searchKeyword + '%\'';
            result = Database.Query(sql);
      }
     
      /*    Getting and Setting values for SearchCategory radio button    */
      public String getsearchCategory()
      {
            return searchCategory;
      }
     
      public void setsearchCategory(String searchCategory)
      {
            this.searchCategory = searchCategory;
      }    
} 


Output:


Cheers!!!

Documents for Salesforce

Click the below link to get documents for Salesforce

http://wiki.developerforce.com/page/Documentation

How to convert sObject to String in Apex

To convert sObject to String in Apex, below i s the simple code


Example:


public sObject searchCategory;
String objType = String.valueOf(searchCategory);

Radio Button selected by default in Visualforce page


Below is the simple code to select Radio button by default in Visualforce page.


Visualforce:


<apex:selectRadio value="{!searchCategory}" >
    <apex:selectOption itemValue="Member" itemlabel="Member"/>
    <apex:selectOption itemValue="Blog" itemlabel="Blog"/>
    <apex:selectOption itemValue="Photo" itemlabel="Photo"/>
</apex:selectRadio>


Apex:


public class search 
{
..........................................................
..........................................................
// Constructor of the class
public search()
{
searchCategory = 'Member';
}
..........................................................
..........................................................
}

Like operator in Salesforce

Example:

String sql = 'Select Name From Account WHERE Name LIKE \'%' + searchKeyword + '%\'';

where searchKeyword is an Apex variable.

or

List<Contact> listCon = [SELECT Id, FirstName FROM Contact WHERE FirstName LIKE '%test%'];

system.debug('List contacts are ' + listCon);


Cheers!!!

Radio Button in Salesforce


To create Radio button using apex, use <apex:selectRadio>

Example:

Visualforce page:

<apex:selectRadio value="{!searchCategory}" >
    <apex:selectOption itemValue="Member" itemlabel="Member"/>
    <apex:selectOption itemValue="Blog" itemlabel="Blog"/>
    <apex:selectOption itemValue="Photo" itemlabel="Photo"/>
</apex:selectRadio>


Apex:

public String searchCategory;

public String getsearchCategory()
{
return searchCategory;
}

public void setsearchCategory(String searchCategory)
{
this.searchCategory = searchCategory;
}

Convert List to Set in Salesforce

The simplest way to convert List to Set in Salesforce is given below:    

        List<String> tempList = new List<String>();
        Set<String> tempSet = new Set<String>();
        
        tempList.add('One');
        tempList.add('Two');
        tempList.add('Three');  
        
        tempSet.addAll(tempList); 

tempList is List datatype and tempSet is Set datatype.
Add some values to List datatype and use addAll() to add it to Set datatype.


Cheers!!!

Popup in Salesforce

Below is the simple example for popup in salesforce

Visualforce page:

<apex:page controller="popup">

<style type="text/css">

        .popup

        {
            background-color: white;
            border-width: 2px;
            border-style: solid;
            z-index: 9999;
            left: 50%;
            padding:10px;
            position: absolute;
            width: 500px;
            margin-left: -250px;
            top:80px;
        }

        .popupBg

        {
            background-color:black;
            opacity: 0.20;
            filter: alpha(opacity = 70);
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            z-index: 9998;
        }

    </style>

   
    <apex:form >
        <apex:commandButton value="Show" action="{!showPopup}" rerender="popup"/>
        <apex:pageBlock >
            Click Show button for popup.
        </apex:pageBlock>

        <apex:outputPanel id="popup">

        <apex:outputPanel styleClass="popupBg" layout="block" rendered="{!displayPopUp}"/>
            <apex:outputPanel styleClass="popup" layout="block" rendered="{!displayPopUp}">
                Popup window
                <apex:commandButton value="Hide" action="{!closePopup}" rerender="popup"/>
            </apex:outputPanel>
        </apex:outputPanel>

    </apex:form>

</apex:page>

Apex:

public class popup
{    
    public boolean displayPopup {get; set;}    
   
    public void closePopup()
    {      
        displayPopup = false;  
    }    
    public void showPopup()
    {      
        displayPopup = true;  
    }  
  }

Ouput:




Cheers!!!

To display pageblock button in bottom alone

Location attribute is important to display pageblock button in bottom alone.

<apex:pageblock title="Members" >
    <apex:pageBlockTable value="{!memb}" var="mem">
        <apex:column value="{!mem.Name}"/>
        <apex:column value="{!mem.E_Mail_Id__c}"/>
        <apex:column value="{!mem.Mobile_Number__c}"/>
    </apex:pageBlockTable>
    <apex:pageBlockButtons location="bottom">
        <apex:commandButton value="Ok" action="{!closePopup}"/>
    </apex:pageBlockButtons>
</apex:pageblock>


Cheers!!!

To display pageblock button in top alone

Location attribute is important to display pageblock button in bottom alone.

<apex:pageblock title="Members" >
    <apex:pageBlockTable value="{!memb}" var="mem">
        <apex:column value="{!mem.Name}"/>
        <apex:column value="{!mem.E_Mail_Id__c}"/>
        <apex:column value="{!mem.Mobile_Number__c}"/>
    </apex:pageBlockTable>
    <apex:pageBlockButtons location="top">
        <apex:commandButton value="Ok" action="{!closePopup}"/>
    </apex:pageBlockButtons>
</apex:pageblock>

Cheers!!!

Inner Popup using Salesforce

Visualforce page:

<apex:page controller="showAll" >
<apex:form >
<!--    CSS Style    -->
<style type = "text/css">

.headr
{
font-size:17px;
font-weight:bold;
color:maroon;
}

.popup
{
background-color: white;
border-width: 2px;
border-style: solid;
z-index: 9999;
left: 50%;
padding:10px;
position: absolute;
width: 500px;
height:60%;
margin-left: -250px;
top: 25px;
overflow:scroll;
}
   
.popupBg
{
background-color:black;
opacity: 0.20;
filter: alpha(opacity = 70);
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 9998;
}

</style>
<!--    End of CSS Style    -->

<apex:pageblock >
<table cellspacing = "7" cellpadding = "7">
<tr>
<td><apex:commandLink styleClass="headr" action="{!members}" reRender="members">Members</apex:commandLink></td>
</tr>
<tr>
<td><apex:commandLink styleClass="headr" action="{!blogs}" reRender="blogs">Blogs</apex:commandLink></td>
</tr>
<tr>
<td><apex:commandLink styleClass="headr" action="{!photos}" reRender="photos">Photos</apex:commandLink></td>
</tr>
</table>
</apex:pageblock>
<apex:outputPanel id="members">
<apex:outputPanel styleClass="popupBg" layout="block" rendered="{!displayPopUp}">
       <apex:outputPanel styleClass="popup" layout="block" rendered="{!displayPopUp}">
       <apex:pageblock title="Members" >
        <apex:pageBlockTable value="{!memb}" var="mem">
        <apex:column value="{!mem.Name}"/>
        <apex:column value="{!mem.E_Mail_Id__c}"/>
        <apex:column value="{!mem.Mobile_Number__c}"/>
        </apex:pageBlockTable>
        <apex:pageBlockButtons location="bottom">
        <apex:commandButton value="Ok" action="{!closePopup}"/>
        </apex:pageBlockButtons>
        </apex:pageblock>
</apex:outputPanel>
</apex:outputPanel>
</apex:outputPanel>

<apex:outputPanel id="blogs">
<apex:outputPanel styleClass="popupBg" layout="block" rendered="{!displayPopUp}">
       <apex:outputPanel styleClass="popup" layout="block" rendered="{!displayPopUp}">
       <apex:pageblock title="Blogs" >
        <apex:pageBlockTable value="{!blog}" var="blg">
        <apex:column value="{!blg.Name}"/>
        <apex:column value="{!blg.URL__c}"/>
        </apex:pageBlockTable>
        <apex:pageBlockButtons location="bottom">
        <apex:commandButton value="Ok" action="{!closePopup}"/>
        </apex:pageBlockButtons>
        </apex:pageblock>
</apex:outputPanel>
</apex:outputPanel>
</apex:outputPanel>

<apex:outputPanel id="photos">
<apex:outputPanel styleClass="popupBg" layout="block" rendered="{!displayPopUp}">
       <apex:outputPanel styleClass="popup" layout="block" rendered="{!displayPopUp}">
       <apex:pageblock title="Photos" >
        <apex:pageBlockTable value="{!photo}" var="pht">
        <apex:column value="{!pht.Name}"/>
        <apex:column value="{!pht.ID}"/>
        </apex:pageBlockTable>
        <apex:pageBlockButtons location="bottom">
        <apex:commandButton value="Ok" action="{!closePopup}"/>
        </apex:pageBlockButtons>
        </apex:pageblock>
</apex:outputPanel>
</apex:outputPanel>
</apex:outputPanel>

</apex:form>
</apex:page>

Apex:

public class showAll
{
    public boolean displayPopup {get; set;}
    public List<Member__c> memb {get;set;}
    public List<Blog__c> blog {get;set;}
    public List<Photo__c> photo {get;set;}
 
    public showAll()
    {
    displayPopup = false;
    }
 
    public void members()
    {
    displayPopup = true;
    String sql = 'SELECT Name,E_Mail_Id__c,Mobile_Number__c FROM Member__c';
    memb = Database.Query(sql);
    }
 
    public void blogs()
    {
    displayPopup = true;
    String sql = 'SELECT Name,URL__c FROM Blog__c';
    blog = Database.Query(sql);
    }  
 
    public void photos()
    {
    displayPopup = true;
    String sql = 'SELECT Name,ID FROM Photo__c';
    photo = Database.Query(sql);
    }
 
    public void closePopup()
    {
    displayPopup = false;    
    }
}

Output: