November 30, 2012

Date picker in Visualforce page

Sample Code1:

Visualforce page:

<apex:page docType="html-5.0" controller="Sample">
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection>
            <apex:pageBlockSectionItem>
                Date: <apex:input type="date" value="{!dat}"/>
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>

Apex Controller:

public class Sample {
    public Date dat {get;set;}
    public Sample() {

    }
}

Output:



Sample Code2:

Visualforce page:

<apex:page controller="datePicker" id="mypage">
    <apex:form>   
       
Date: <apex:inputText value="{!datename}" size="10" id="demo" onfocus="DatePicker.pickDate(false, this , false);" />   
    </apex:form>
</apex:page>


Apex Controller:

public class DatePicker
{
    public String datename {get; set;}
}


Output:



Sample date picker

Sample Code:

<html>

<head>

<script language="JavaScript">

function show_calendar(str_target, str_datetime) {
    var arr_months = ["January", "February", "March", "April", "May", "June",
        "July", "August", "September", "October", "November", "December"];
    var week_days = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
    var n_weekstart = 1; // day week starts from (normally 0 or 1)

    var dt_datetime = (str_datetime == null || str_datetime =="" ?  new Date() : str2dt(str_datetime));
    var dt_prev_month = new Date(dt_datetime);
    dt_prev_month.setMonth(dt_datetime.getMonth()-1);
    var dt_next_month = new Date(dt_datetime);
    dt_next_month.setMonth(dt_datetime.getMonth()+1);
    var dt_firstday = new Date(dt_datetime);
    dt_firstday.setDate(1);
    dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
    var dt_lastday = new Date(dt_next_month);
    dt_lastday.setDate(0);
   
    // html generation (feel free to tune it for your particular application)
    // print calendar header
    var str_buffer = new String (
        "<html>\n"+
        "<head>\n"+
        "    <title>Calendar</title>\n"+
        "</head>\n"+
        "<body bgcolor=\"White\">\n"+
        "<table class=\"clsOTable\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"+
        "<tr><td bgcolor=\"#4682B4\">\n"+
        "<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+
        "<tr>\n    <td bgcolor=\"#4682B4\"><a href=\"javascript:window.opener.show_calendar('"+
        str_target+"', '"+ dt2dtstr(dt_prev_month)+"'+document.cal.time.value);\">"+
        "<img src=\"prev.gif\" width=\"16\" height=\"16\" border=\"0\""+
        " alt=\"previous month\"></a></td>\n"+
        "    <td bgcolor=\"#4682B4\" colspan=\"5\">"+
        "<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"
        +arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</font></td>\n"+
        "    <td bgcolor=\"#4682B4\" align=\"right\"><a href=\"javascript:window.opener.show_calendar('"
        +str_target+"', '"+dt2dtstr(dt_next_month)+"'+document.cal.time.value);\">"+
        "<img src=\"next.gif\" width=\"16\" height=\"16\" border=\"0\""+
        " alt=\"next month\"></a></td>\n</tr>\n"
    );

    var dt_current_day = new Date(dt_firstday);
    // print weekdays titles
    str_buffer += "<tr>\n";
    for (var n=0; n<7; n++)
        str_buffer += "    <td bgcolor=\"#87CEFA\">"+
        "<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"+
        week_days[(n_weekstart+n)%7]+"</font></td>\n";
    // print calendar table
    str_buffer += "</tr>\n";
    while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
        dt_current_day.getMonth() == dt_firstday.getMonth()) {
        // print row heder
        str_buffer += "<tr>\n";
        for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
                if (dt_current_day.getDate() == dt_datetime.getDate() &&
                    dt_current_day.getMonth() == dt_datetime.getMonth())
                    // print current date
                    str_buffer += "    <td bgcolor=\"#FFB6C1\" align=\"right\">";
                else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
                    // weekend days
                    str_buffer += "    <td bgcolor=\"#DBEAF5\" align=\"right\">";
                else
                    // print working days of current month
                    str_buffer += "    <td bgcolor=\"white\" align=\"right\">";

                if (dt_current_day.getMonth() == dt_datetime.getMonth())
                    // print days of current month
                    str_buffer += "<a href=\"javascript:window.opener."+str_target+
                    ".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+
                    "<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">";
                else
                    // print days of other months
                    str_buffer += "<a href=\"javascript:window.opener."+str_target+
                    ".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+
                    "<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
                str_buffer += dt_current_day.getDate()+"</font></a></td>\n";
                dt_current_day.setDate(dt_current_day.getDate()+1);
        }
        // print row footer
        str_buffer += "</tr>\n";
    }
    // print calendar footer
    str_buffer +=
        "<form name=\"cal\">\n<tr><td colspan=\"7\" bgcolor=\"#87CEFA\">"+
        "<font color=\"White\" face=\"tahoma, verdana\" size=\"2\">"+
        "Time: <input type=\"text\" name=\"time\" value=\""+dt2tmstr(dt_datetime)+
        "\" size=\"8\" maxlength=\"8\"></font></td></tr>\n</form>\n" +
        "</table>\n" +
        "</tr>\n</td>\n</table>\n" +
        "</body>\n" +
        "</html>\n";

    var vWinCal = window.open("", "Calendar",
        "width=200,height=250,status=no,resizable=yes,top=200,left=200");
    vWinCal.opener = self;
    var calc_doc = vWinCal.document;
    calc_doc.write (str_buffer);
    calc_doc.close();
}
// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt (str_datetime) {
    var re_date = /^(\d+)\-(\d+)\-(\d+)\s+(\d+)\:(\d+)\:(\d+)$/;
    if (!re_date.exec(str_datetime))
        return alert("Invalid Datetime format: "+ str_datetime);
    return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6));
}
function dt2dtstr (dt_datetime) {
    return (new String (
            dt_datetime.getDate()+"-"+(dt_datetime.getMonth()+1)+"-"+dt_datetime.getFullYear()+" "));
}
function dt2tmstr (dt_datetime) {
    return (new String (
            dt_datetime.getHours()+":"+dt_datetime.getMinutes()+":"+dt_datetime.getSeconds()));
}

</script>

</head>

<body>

<form name="tstest">

Date:&nbsp;&nbsp;&nbsp;
<input type="Text" name="timestamp" value="">
    <a href="javascript:show_calendar('document.tstest.timestamp', document.tstest.timestamp.value);">
        <img src="cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp">
    </a>

</form>

</body>

</html>


Download the below images:




Output:

Multiple Approvers in Approval process in Salesforce

If you specify multiple approvers in the Automatically assign to approver(s) option, choose one of the following:
1. Approve or reject based on the first response

The first response to the approval request determines whether the record is approved or rejected.
2. Require unanimous approval from all selected approvers

The record is only approved if all of the approvers approve the request. The approval request is rejected if any of the approvers reject the request.
Cheers!!!

November 29, 2012

Upserting data using Apex Data Loader

Loads data from a data source into Salesforce, where existing records with a matching custom external ID field are updated; records without matches are inserted as new records.

If you are performing an upsert:

  1. Your CSV file must contain a column of ID values for matching against existing records. The column may be either an external ID (a custom field with the “External ID” attribute), or Id (the Salesforce record ID). From the drop-down list, select which field to use for matching. If the object has no external ID fields, Id is automatically used. For more information on external IDs, see “Custom Field Attributes” in the online help. Click Next to continue.
  2. If your file includes the external IDs of an object that has a relationship to your chosen object, enable that external ID for record matching by selecting its name from the drop-down list. If you make no selection here, you can use the related object's Id field for matching by mapping it in the next step. Click Next to continue.
Cheers!!!

Difference between Export and Export All

Export :  It is used to export the Salesforce Data(excluding recycle bin's data) into your local  system.

Export All :  It is used to export the Salesforce Data(including recycle bin's data) into your local system.

Cheers!!!

Salesforce.com Releases per year

Salesforce.com Releases per year are as follows
    1)  Spring (February to May)

    2)  Summer(June to September)

    3)  Winter(October to January)
      The exact dates of the releases are published a month or so in advance.

      https://trust.salesforce.com is the best place to find out the exact date for a particular release.

      Cheers!!!

      Welcome message and update notification trigger in Salesforce

      Sample Code:

      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 + ',<br>Welcome to Sweet 16.<br><br><b>Regards,</b><br>Magulan D</body></html>';
                  mail.setHtmlBody(messageBody);  
              }
             
              //Email notification
              if(trigger.isUpdate)
              {
                  mail.setSubject('Updates in your details');
                  messageBody = '<html><body>Hi ' + member.Name + ',<br>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 });
          }
      }

      Executing Trigger based on field value in Salesforce

      Sample Trigger:

       trigger test on Member__c (after insert)
      {
          List<Case> cases = new List<Case>();

          for(Member__c mem:Trigger.new)
          {
              if(
      mem.Comments__c != null || mem.Comments__c != '')
              {
                      Case newCase = new Case(subject='Material',Status='New',Origin='Web');           
                      insert newCase;

              }
          }

      }

      How to convert String to Id?

      Sample Code:

      String a = 'adfh123edrftghu789';
      Id i = Id.valueOf(a);

      here String 'a' should be a valid record id. We cannot generate Salesforce Id using this method because Salesforce Id is system generated Id and it cannot be generated by us.


      Cheers!!!

      November 28, 2012

      How to use Custom Labels in Visualforce page and Apex Class

      Custom labels are custom text values that can be accessed from Apex classes or Visualforce pages. The values can be translated into any language Salesforce supports. Custom labels enable developers to create multilingual applications by automatically presenting information (for example, help text or error messages) in a user's native language.

      You can create up to 5,000 custom labels for your organization, and they can be up to 1,000 characters in length.

      1. Go to Setup --> App Setup --> Custom Labels.

      2. Click 'New Custom Label' Button.


      3. Fill in the details and Click 'Save' button.



      Calling Custom Label in Visualforce page:
       
      Use the global variable $Label to access the Custom Label value in Visualforce page.

      Sample Code:

      <apex:page standardController="Account" extensions="sample">
      <h1>Example for Custom labels</h1>
      <apex:outputLabel value="{!$Label.Sample}"/>
      </apex:page>



      Using Custom Label in Apex Class:

      Custom labels are called in Apex using System.Label.Label_name.

      Sample Code:

      String samp = System.Label.Sample;

      Cheers!!!

      Outbound Messaging in Salesforce

      Using Outbound Messaging a message is sent to the specified endpoint URL. The message contains the fields specified when you created the outbound message. Once the endpoint URL receives the message, it can take the information from the message and process it. To do that, you need to examine the outbound messaging WSDL. Salesforce must be configured to send outbound messages before the publisher will receive any data.

      When setting up the outbound message, be sure to define these settings.
      1. Endpoint URL
      2. Fields to send
      3. Include session ID
      1. Go to Build --> Create --> Workflow & Approvals --> Outbound Messages.


      2. Click "New Outbound Message" button.


      3. Select the object and click "Next" button.


      4. Enter the details and click "Save" button.


      5. Go to Build --> Create --> Workflow & Approvals --> Workflow Rules and click "New Rule".



      6. Select the object and click "Next" button.


      7. Enter the details and click "Save&Next" button.


      8. Click "Select Existing Action".


      9. Select the outbound message and click "Save" button.


      10. Click "Done" button.


      11. Click "Activate" button.


      November 27, 2012

      Topics in Salesforce

      CRM Introduction
      What is CRM?
      CRM Basic entities
       
      Salesforce.com Introduction
      What is Salesforce.com?
      Why Salesforce.com?
      Different editions in Salesforce.com
      How to sign up for Developer Edition?
       
      Level 1(Setup and Config) 
      Types of Objects
      1. Standard Objects
      2. Custom Objects
       
      Types of Fields
      1. Standard Fields
      2. Custom Fields
       
      Validation Rules
      Email to Case
      Web-to-Lead
      Web-to-Case
       
      Types of Relationships
      1. Lookup
      2. Master Detail
       
      Different types of tabs
      1. Custom Object Tab
      2. Web Tab
      3. Visualforce Tab
      4. Lightning Component Tab
       
      Types of Applications
      1. Custom application
      2. Console application
       
      Different types of Email templates
      1. Text
      2. HTML (using Letterhead)
      3. Custom (without using Letterhead)
      4. Visualforce
       
      Workflow rules
      1. Email Alert
      2. Task
      3. Field Update
      4. Outbound Message
       
      Field Dependency
      Field History Tracking
      Feed Tracking
      Dev and Admin Help Community
      View setup audit trail
       
      Security and Data Access
      1. Organization Wide Default
      2. Role Hierarchy
      3. Sharing Rules
      4. Manual Sharing 
      5. Object Permission
      6. Profiles
      7. Permission Sets
       
      Account, Opportunity & Case Teams
      Renaming Tab Names and Labels 
      Escalation Rules
      Account Hierarchy
      Queues
      Public Groups
      Reports and Dashboards
      Scheduling reports
      Grant Login Access
      Setting IP Ranges
      Trusted IP Ranges
      Login Hours restriction for Profiles
      Approval process
      Assignment Rules
      Auto Response Rule
      Views
      Domain Registration
      Search Layouts
      Search Results
      Lookup Dialogs
      Lookup Phone Dialogs
      Accounts Tab
      Accounts List View
      Search Filter Fields
      Page Layout
      Duplicate Management
      Record Types
      Lightning Record Page
      Force.com Sites
      Data Management
      Analytic Snapshots
      Import Accounts/Contacts
      Import Leads
      Import Solutions
      Import Custom Objects
      Data Export
      Storage Usage
      Mass Transfer Records
      Mass Delete Records
      Mass Transfer Approval Requests
      Mass Update Addresses
      Data Loader
      Tags in Salesforce
      Schema Builder
      Process Builder
      Flows
      Community/Experience Cloud
      Chat
      Embedded Service Deployment
      Einstein Bot
      Quick Text
      Custom Label
      Custom Settings
      Custom Metadata Type

      Level 2(Coding and Development)
      Visualforce Page
      Aura Component
      LWC or Lightning Web Component
       
      Apex Class
      1. Custom Controller and Extensions 
      2. Best Practices
      3. Data Types
      4. Batch Apex
      5. Future Methods
      6. Queueable Interface
      7. Unit Testing or Test Class
      8. Debugging
      9. With Sharing and Without Sharing in Apex Classes
       
      Apex Trigger
      1. Trigger development with handler classes
      2. Best Practices
      3. Recursive Trigger
       
      Integration
      1. Standard REST API
      2. Outbound REST API with XML Response using Apex
      3. Outbound REST API with JSON Response using Apex
      4. Inbound REST API using Apex
      5. Outbound SOAP API using Apex
       
      Governor Limits in Salesforce
      Order of Execution in Salesforce
      SOQL

      Salesforce Integration Document

      How to schedule a report

      1. Open the report.

      2. Click 'Schedule Future Runs...' link in 'Run Report' list button.



      3. Fill the data as per your request and click 'Save Schedule Report' button.



      Sample scheduled report email:




      Cheers!!!

      November 26, 2012

      How to add Row limit and Dashboard settings for Tabular report

      Open the tabular report and click Filter list and select row limit


      Now click 'Dashboard Settings' button and select Name and value click 'Ok' button.




      The value field can be anyone of the following data types

      1. Number
      2. Currency
      3. Boolean

      Cheers!!!

      How to display multiple Dashboards in home page in Salesforce

      To display multiple Dashboards in home page, just add the charts to the space adjacent to the chart.


      Click 'Save' and check your home page now.

      Updating field using Javascript using a custom button

      1. Create a button with label 'Add Employee'.

      2. Select '

      3. Select 'Execute JavaScript' as a behaviour.

      4. Add the below code

      {!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}

      var newRecords = [];

      var a = new sforce.SObject("Account");

      a.id ="{!Account.Id}";
      a.NumberOfEmployees = {!Account.NumberOfEmployees} + 1;
      newRecords.push(a);

      result = sforce.connection.update(newRecords);

      window.location.reload();


      5. Click 'Save' button.

      6. Add the button to the page layout.




      It will increment the Employees.

      How to track field history in Salesforce

      To track field history in Salesforce, follow the below steps

      1. Select the object.
      2. In the Custom fields section, click 'Set History Tracking' button.


      3. Select the fields and click 'Save' button.


      4. Add History related list to the page layout to see the changes.




      To change the dashboard to be displayed in Home page in Salesforce

      To change the dashboard to be displayed in Home page in Salesforce, follow the below steps

      1. Click 'Customize page' link.


      2. Select the dashboard to be displayed.

      How to display Dashboard on home page in Salesforce

      Go to Setup-> App setup ->customize-> Home -> Home page layout -> DE Default, Click 'Edit' and check the 'Dashboard snapshot' checkbox and click 'Save' button.

      Fetching data from another Salesforce organization

      Step 1: Generate Partner WSDL.




      Save the generated Partner WSDL.

      Step 2: Generate Apex code using the generated Partner WSDL.

       




      Copy the generated code and create a new Apex Class.

      Note:
      In the generated code do the following changes.
      1. Change public partnerSoapSforceCom.DeleteResult[] delete(String[] ids)  to public partnerSoapSforceCom.DeleteResult[] deleteSObjects(String[] ids).
      2. Change public partnerSoapSforceCom.UpsertResult[] upsert(String externalIDFieldName,sobjectPartnerSoapSforceCom.sObject_x[] sObjects) to public partnerSoapSforceCom.UpsertResult[] upsertSObjects(String externalIDFieldName,sobjectPartnerSoapSforceCom.sObject_x[] sObjects).
      3. Change public partnerSoapSforceCom.MergeResult[] merge(partnerSoapSforceCom.MergeRequest[] request) to public partnerSoapSforceCom.MergeResult[] mergeSObjects (partnerSoapSforceCom.MergeRequest[] request).
      4. Change public partnerSoapSforceCom.SaveResult[] update(sobjectPartnerSoapSforceCom.sObject_x[] sObjects) to public partnerSoapSforceCom.SaveResult[] updateSObjects(sobjectPartnerSoapSforceCom.sObject_x[] sObjects).
      5. Change public partnerSoapSforceCom.UndeleteResult[] undelete(String[] ids) to public partnerSoapSforceCom.UndeleteResult[] undeleteSObjects(String[] ids).
      Step 3:  Create visual force page to get the following details

      • Login credentials
      • Object Names
      • Field Names
      • Records

      Sample Code:

      <apex:page controller="sfTosf" >

      <!-- Javascript -->
      <script type = "text/javascript">

          window.onload=function()      
          {         
              document.getElementById("objs").style.display = 'none';
              document.getElementById("fields").style.display = 'none';
              document.getElementById("records").style.display = 'none';
          };
         
          function callObjects()
          {
              document.getElementById("objs").style.display = '';
              CallLogin();
          }

          function callFields()
          {
              document.getElementById("fields").style.display = '';
              CallShowFields();
          }
         
          function callRecords()
          {
              document.getElementById("records").style.display = '';
              CallShowRecords();
          }
         
      </script>
      <!-- End of Javascript -->

      <apex:form >
          <!-- Action Status -->
          <apex:actionstatus id="actionStatus">
          <apex:facet name="start">
          <c:enhancedactionstatus BackColor="#efefef" borderColor="black" borderSize="3" height="50px" width="120px" Message="Loading..." messageStyle="color:darkred;font-size:11pt;font-weight:bold;"/>
          </apex:facet>
          </apex:actionStatus>
         
          <!-- Calling login() from Controller -->
          <apex:actionFunction name="CallLogin" action="{!login}" reRender="objs" status="actionStatus"/>   

          <!-- Calling showFields() from Controller -->
          <apex:actionFunction name="CallShowFields" action="{!showFields}" reRender="fields" status="actionStatus"/>
         
          <!-- Calling fetch() from Controller -->
          <apex:actionFunction name="CallShowRecords" action="{!fetch}" reRender="records" status="actionStatus"/>    

          <!-- Login Details -->
          <apex:pageblock title="Login" >
              <apex:pageblocksection columns="2">
                  <apex:outputLabel >Username:</apex:outputLabel>
                  <apex:inputtext value="{!userName}" />
                  <apex:outputLabel >Password:</apex:outputLabel>
                  <apex:inputsecret value="{!passWord}"  />          
                  <apex:outputLabel >Security Token:</apex:outputLabel>                       
                  <apex:inputsecret value="{!securityToken}"  />             
              </apex:pageblocksection>                      
              <apex:pageblockbuttons >
                  <apex:commandButton value="Login" reRender="objs" onclick="callObjects()"/>
              </apex:pageblockbuttons>           
          </apex:pageblock>
         
          <!-- Object Details -->
          <table id = "objs" width = "100%"><tr><td>
          <apex:pageblock id="objs" title="Object Selection">
              <apex:pageblocksection >
                  <apex:outputlabel >Select Object:</apex:outputlabel>
                  <apex:selectList value="{!objectName}" multiselect="false" size="1" onchange="callFields()" >
                      <apex:selectoptions value="{!ObjectNames}"/>
                  </apex:selectList>
              </apex:pageblocksection>
          </apex:pageblock>
          </td></tr></table>
         
          <!-- Fields Details -->
          <table id = "fields" width = "100%"><tr><td>
          <apex:pageblock id="fields" title="Fields Selection">
              <table cellspacing = "15">
                  <tr>
                      <td>
                          <apex:selectList multiselect="true" value="{!selectedFields}" size="7" >
                              <apex:selectoptions value="{!fields}"/>
                          </apex:selectList>
                      </td>
                      <td>
                          <apex:commandButton value=" >> " action = "{!addFields}" reRender = "fields" status="actionStatus"/><br/><br/><br/><br/>
                          <apex:commandButton value=" << " action="{!removeFields}" reRender="fields" status="actionStatus"/>  
                      </td>
                      <td>
                          <apex:selectList multiselect="true" value="{!checkedFields}" size="7">
                              <apex:selectoptions value="{!fieldsAvailable}"/>
                          </apex:selectList>
                      </td>               
                  </tr>
                  <tr>
                      <td colspan = "3" align = "center"><apex:commandButton value="Fetch" rerender="records" onclick="callRecords()"/></td>
                  </tr>
              </table>
          </apex:pageblock>
          </td></tr></table>
         
          <!-- Retrieved Records -->   
          <table id = "records" width = "100%"><tr><td>
          <apex:pageBlock id="records" title="Records">
              <apex:pageBlockTable value="{!output}" var="res">
                  <apex:column value="{!res}"/>
              </apex:pageBlockTable>
          </apex:pageBlock>
          </td></tr></table>  
           
      </apex:form>
      </apex:page>

      Step 4:  Write an apex class for controller to that visualforce page.

      Sample Code:

      public class sfTosf
      {
          public String userName {get;set;}   
          public String passWord {get;set;}
          public String securityToken {get;set;}  
          public String objectName {get;set;}
          public String[] objNames = new String[]{'None'};
          public List<String> fieldNames = new List<String>();
          public List<String> availableFieldNames = new List<String>();
          public sobjectPartnerSoapSforceCom.sObject_x[] values;  
          public List<String> output {get; set;}
          public integer i {get;set;}
          public integer j = 0;
             
          /* String array for select box(Fields) */
          String[] selectedFields = new String[]{};
          String[] checkedFields = new String[]{};
         
          public partnerSoapSforceCom.Soap con = new partnerSoapSforceCom.Soap();
         
          public void login()
          {
              if(checkLogin())
              {
                  retrieveObjects();
              }
          }
         
          public boolean checkLogin()
          {
              try
              {                                 
                  partnerSoapSforceCom.LoginResult loginResult = con.login(username, (password+securityToken));                   
                  con.SessionHeader = new partnerSoapSforceCom.SessionHeader_element();       
                  con.endpoint_x =loginResult.ServerUrl;       
                  con.Sessionheader.sessionid = loginResult.sessionid;
              }
              catch(Exception e)
              {
              }
              return true;
           }
          
           /* Retrieving all the objects */
           public void retrieveObjects()
           {
               if(checkLogin())
               {
                   partnerSoapSforceCom.DescribeGlobalresult sobjectResults = con.describeGlobal();
                   partnerSoapSforceCom.DescribeGlobalSObjectResult[] objects = sobjectResults.sobjects;        
                   for(partnerSoapSforceCom.DescribeGlobalSObjectResult tmpRes:objects)
                   {
                       objNames.add(tmpRes.Name);
                   }
               }
           }
          
           /* Getting the selected object name */
           public String getobjectName()    
           {     
               return objectName;   
           }       
           public void setobjectName(String obj)    
           {     
               this.objectName = objectName;    
           }
           
           public List<SelectOption> getobjectNames()   
           {         
               List<SelectOption> options = new List<SelectOption>();
               for(String temp:objNames)
               {    
               options.add(new SelectOption(temp,temp));
               }     
               return options;   
           }
          
           public void showFields()
           {
               if(checkLogin())
               {
                   partnerSoapSforceCom.DescribeSObjectResult descObjRes = con.describeSObject(objectName);
                   partnerSoapSforceCom.Field[] fields = descObjRes.Fields;
                   for(partnerSoapSforceCom.Field tmpRes:fields)
                   {
                       fieldNames.add(tmpRes.Name);               
                   }                    
               }        
           }
          
           /* Getting the all the field names */
           public List<String> getselectedFields()    
           {     
               return selectedFields;   
           }       
           public void setselectedFields(List<String> selectedFields)    
           {     
               this.selectedFields = selectedFields;   
           }
                
           public List<SelectOption> getfields()   
           {         
               List<SelectOption> options = new List<SelectOption>();
               fieldNames.sort();
               for(String temp:fieldNames)
               {    
               options.add(new SelectOption(temp,temp));
               }     
               return options;   
           }
          
           /* Getting the all the field names */
           public List<String> getcheckedFields()    
           {     
               return checkedFields;   
           }       
           public void setcheckedFields(List<String> checkedFields)    
           {     
               this.checkedFields = checkedFields;   
           }
                
           public List<SelectOption> getfieldsAvailable()   
           {         
               availableFieldNames.sort();
               List<SelectOption> options = new List<SelectOption>();
               for(String temp:availableFieldNames)
               {    
                   options.add(new SelectOption(temp,temp));
               }     
               return options;   
           }
          
           public void addFields()
           {
               for(String tmp:selectedFields)
               {
                   availableFieldNames.add(tmp);
                   for(i = 0; i<fieldNames.size(); i++)
                   {
                       if(fieldNames[i] == tmp)
                       {
                           fieldNames.remove(i);
                           break;
                       }
                   }                         
               }
           }   
          
           public void removeFields()
           {
               integer i;
               for(String tmp:checkedFields)
               {
                   fieldNames.add(tmp);
                   for(i = 0; i<availableFieldNames.size(); i++)
                   {
                       if(availableFieldNames[i] == tmp)
                       {
                           availableFieldNames.remove(i);
                           break;
                       }
                   }                         
               }
           }
           public void fetch()
           {
               if(checkLogin())
               {
                   integer availableFieldNamesLen = availableFieldNames.size();
                   String fieldsToQuery = '';
                   for(String temp:availableFieldNames)
                   {
                       if(j != (availableFieldNameslen - 1))
                       {
                           fieldsToQuery = fieldsToQuery + temp + ',';
                       }
                       else
                       {
                           fieldsToQuery = fieldsToQuery + temp;
                       }                
                       j = j +1;
                   }
                   String sql = 'SELECT ' + fieldsToQuery + ' FROM ' + objectName;              
                      
              
                   /*-----------------------------------
                   Login via SOAP/XML web service api
                  -----------------------------------*/
                  HttpRequest request = new HttpRequest();
                  request.setEndpoint('https://www.salesforce.com/services/Soap/u/22.0');
                  request.setMethod('POST');
                  request.setHeader('Content-Type', 'text/xml;charset=UTF-8');
                  request.setHeader('SOAPAction', '""');
                  /*not escaping username and password because we're setting those variables above
                  in other words, this line "trusts" the lines above
                  if username and password were sourced elsewhere, they'd need to be escaped below*/
                  request.setBody('<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Header/><Body><login xmlns="urn:partner.soap.sforce.com"><username>' + userName+ '</username><password>' + passWord + securityToken + '</password></login></Body></Envelope>');
                  Dom.XmlNode resultElmt = (new Http()).send(request).getBodyDocument().getRootElement()
                    .getChildElement('Body', 'http://schemas.xmlsoap.org/soap/envelope/')
                    .getChildElement('loginResponse', 'urn:partner.soap.sforce.com')
                    .getChildElement('result', 'urn:partner.soap.sforce.com');
         
                  /*-------------------------------
                   Grab session id and server url
                  --------------------------------*/
                  final String SERVER_URL = resultElmt.getChildElement('serverUrl', 'urn:partner.soap.sforce.com') .getText().split('/services')[0];
                  final String SESSION_ID = resultElmt.getChildElement('sessionId', 'urn:partner.soap.sforce.com') .getText();
         
                  /*----------------------------------
                   Load first 20 accounts via REST API
                  ---------------------------------*/
                  final PageReference theUrl = new PageReference(SERVER_URL + '/services/data/v22.0/query/');
                  theUrl.getParameters().put('q',sql);
                  request = new HttpRequest();
                  request.setEndpoint(theUrl.getUrl());
                  request.setMethod('GET');
                  request.setHeader('Authorization', 'OAuth ' + SESSION_ID);
         
                  String body = (new Http()).send(request).getBody();
         
                  JSONParser parser = JSON.createParser(body);
         
                  do
                  {
                      parser.nextToken();
                  }
                  while(parser.hasCurrentToken() && !'records'.equals(parser.getCurrentName()));
         
                  parser.nextToken();
         
                  List<String> tmpOutput = (List<String>) parser.readValueAs(List<String>.class); 
                  //output = tmpOutput;                   
                  List<String> tempoutput = new List<String>();
                  for(String tmp:tmpOutput)
                  {
                      if(tmp != null)
                      {
                          if(!tmp.contains('attributes') && !tmp.contains('type') && !tmp.startsWith('/services/data/v22.0') && !tmp.contains('url') && tmp != objectName && !tmp.contains('{') && !tmp.contains('}'))
                          {
                              tempoutput.add(tmp);
                          }
                      }
                  }
                  output = tempoutput;
              } 
           } 
      }

      Step 5:  Create a custom component for action status with name “enhancedactionstatus”.
      To create custom component, Setup à Develop à Components


      enhancedactionstatus custom component

      Sample Code:
      <apex:component >
      <!-- Attribute Definitions -->
      <apex:attribute name="BorderColor" type="String" required="true" description=""></apex:attribute>
      <apex:attribute name="Width" type="String" required="true" description=""></apex:attribute>
      <apex:attribute name="Height" type="String" required="true" description=""></apex:attribute>
      <apex:attribute name="BackColor" type="String" required="true" description=""></apex:attribute>
      <apex:attribute name="BackColor" type="String" required="true" description=""></apex:attribute>
      <apex:attribute name="BorderSize" type="String" required="true" description=""></apex:attribute>
      <apex:attribute name="ImageUrl" type="String" required="false" description=""></apex:attribute>
      <apex:attribute name="Message" type="String" required="false" description=""></apex:attribute>
      <apex:attribute name="messageStyle" type="String" required="false" description="Message inline style">
      </apex:attribute>
      <apex:attribute name="BorderStyle" type="String" 
      required="false" description="Message box border style: solid, outset, inset, etc"></apex:attribute>
       
      <div id="salesforceSource_blurybackground" style="position:absolute; left:1px; top:1px; 
      width:100%; height:100%; text-align:center; vertical-align: 
      middle; background-color: #303030; opacity:0.6; filter:alpha(opacity=50)">
      </div>
       
      <div id="salesFroceSource_StatusBox" 
      style="position:absolute; left:100px; top: 100px;width: {!Width}; height:{!Height}; filter:alpha(opacity=100)">
      <table border="{!BorderSize}" cellpadding="0" cellspacing="0" style="border-left-color: {!BorderColor};
      border-bottom-color: {!BorderColor}; width: {!Width}; border-top-color: {!BorderColor}; height:{!Height};
      border-right-color:{!BorderColor}; border-style:{!BorderStyle}; background-color:{!BackColor};">
      <tr>
      <td align = "center" style="border-bottom-color:{!BorderColor}; border-bottom-width:1px; 
      border-bottom-style:solid;vertical-align:middle;{!messageStyle}">
      &nbsp;{!Message}
      </td>
      </tr>
      </table>
      </div>
       
      <script type="text/javascript">
      var AgreementForm = document.getElementById("salesforceSource_blurybackground");
      AgreementForm.style.height = window.screen.availHeight + "px";
      AgreementForm.style.width = window.screen.availWidth + "px";
       
      var ContainerElem = document.getElementById("salesFroceSource_StatusBox");
      //ContainerElem.style.display = "block";
      AlignToCenter(ContainerElem);
       
      function AlignToCenter(Element)
      {
      var availableHeight = 0;
      var availableWidth = 0;
      if (Element.ownerDocument)
      {
      var docElement = Element.ownerDocument.documentElement;
      availableHeight = parseInt(docElement.clientHeight);
      if (availableHeight == "NaN") availableHeight = 0;
       
      availableWidth = parseInt(docElement.clientWidth);
      if (availableWidth == "NaN") availableWidth = 0;
      }
       
      if (availableHeight == 0 || availableHeight == "NaN")
      availableHeight = window.screen.availHeight - 200;
      if (availableWidth == 0 || availableWidth == "NaN")
      availableWidth = window.screen.availWidth - 100;
       
      var msgBoxTop = parseInt((availableHeight - parseInt(Element.clientHeight))/2);
      var msgBoxleft = parseInt((availableWidth - parseInt(Element.style.width))/2);
       
      if (msgBoxTop == "NaN" || msgBoxTop == 0)
      msgBoxTop = 100;
       
      Element.style.left = msgBoxleft + "px";
      Element.style.top = msgBoxTop + "px";
      }
      </script>
      </apex:component>

      Output: