Friday 24 June 2011

How to Use ANT in salesforce


Hi friends here We will learn How to deal with deployment process using ANT. If you have ANT then fine
other wise download apache-ant-1.8.2 or higher version and go through these steps for installing ANT.
Step 1 Download apache-ant-1.8.2-bin from Web.
step 2 install jdk1.6.0_25 or higher version.
Step 3 go to run command use command sysdm.cpl press "advanced" tab then press "environment variable" tab then system variable section press on
tab "New"

create two variable ANT_HOME and JAVA_HOME
ANT_HOME D:\apache-ant-1.8.2-bin\apache-ant-1.8.2 (if your ant folder is in D- drive)                  
JAVA_HOME C:\Program Files\Java\jdk1.6.0_25 (give path of jdk)
now check there will be a another variable "PATH" in that you need to append these newly created variable's with bin location value separating with semicolon.

PATH append like this oldpath; C:\ProgramFiles\Java\jdk1.6.0_25\jre\bin;D:\apache-ant-1.8.2-bin\apache-ant-1.8.2\bin;
(if path variable is already a variable then append this also other wise create new Path variable)

Step4: Go to Salesforce - Setup -. Tool-> Force.com migration download it.
Step5: Extract this downloded zip folder and copy ant-salesforce jar file and put it in lib folder in apache folder.

for more detail go to
http://ant.apache.org/manual/index.html

Now we move to "How to Use ANT for deployment in Apex"

for this Process
1) First of all create package.xml(depends requirement )
2) And Use build.xml and
3) build.property (change credential according to your requirement)








Thursday 23 June 2011

Conditional Style and disabled attribute in Apex

I faced a problem that how we can use some attributes like style and disabled on any condition .
Here I want to share the approach that -
1) How to apply style on any condition
2) How to use disabled on any condition
Explanation  is given below with an example (To disable locked Accounts and to change background color for that account )

VF Page code :-
  

    
        
            
                
                    
                    
                           
                       
                
             
           
               
                   
               
       
   


Controller Code:-
  
public with sharing class Styewithcondition {
    public List accList{get;set;}
    //constructor 
    public styewithcondition(){
        accList = [select name,Locked__c from Account where name like 'a%'];
    }
    public void lockAccount(){
        update accList;
    }
    public void UnlockAllAccount(){
       for(Account a:  accList )
       {   if(a.locked__c == true)
           a.locked__c = false;
       }
       update accList;
    }
}

Screen Shot :-
By this code you can lock and unlock Account from a single list.