Thursday, May 14, 2015

Backup and Restore Salesforce Project usnig Force.com IDE in Eclipes

Backup Salesforce Project:

Download eclipse  and install force.com IDE ref  click here

Create Force.com project. and choose all metadata component 




Copy the project your workspace location


Restore Salesforce Project.


Copy force.com project in your system.(where you want to restore.)

Right click  and select import then Choose "Existing projects in to workspace"




Select Project location and then click finish.




Wednesday, May 13, 2015

Select multiple record from list view using StandardSetController with Javascript validation

Create apex class 


public class conContactList{

   public Integer  numberofRecord{get;set;}
   public List<Contact> ContactList{get;set;}
    public conContactList(ApexPages.StandardSetController controller) 
    {
         ContactList=controller.getSelected();
        numberofRecord=ContactList.Size();
       
    }
    public List<Contact>getContactListSF()
    {
       List<Contact> NewContactList=[Select c.Id, FirstName,LastName,Phone from Contact c Where c.Id In : ContactList] ;
       return NewContactList;
    }
   
}

Visualforce page

<apex:page standardController="Contact" recordSetVar="Contact" extensions="conContactList" 
cache="true" >
<apex:outputText value="{!numberofRecord}"></apex:outputText>
<apex:pageblock Title="List of contacts" >
 <apex:pageBlockTable value="{!ContactListSF}" var="a" >
   <apex:column headervalue="First Name" value="{!a.FirstName}"  /> 
   <apex:column headervalue="Last Name" value="{!a.LastName}"  /> 
   <apex:column headervalue="Last Name" value="{!a.Phone}"  /> 
   
 </apex:pageBlockTable>
 </apex:pageblock>
</apex:page>

Javascript Button 

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/16.0/apex.js")}
var records = {!GETRECORDIDS($ObjectType.Contact)};
var strIDs='';
if (records[0] == null)
{
    alert('Please select a record');
}
else
{
  var sApi='{!$Api.Partner_Server_URL_290}';
  var sindex=sApi.indexOf('//');
  var Eindex=sApi.indexOf('.');
 var server=sApi.substring(sindex+2,Eindex)  //*** getting server information *****

//this.form.action = 'https://c.'+server+'.visual.force.com/apex/ContactList?wrapMassAction=1&scontrolCaching=1'; 
this.form.action = 'https://gs78.'+server+'.visual.force.com/apex/ContactList?wrapMassAction=1&scontrolCaching=1'; //*** You must need to full url Other wise you loss selected record***
this.form.submit();
}