• Vadivel Murugan
  • NEWBIE
  • 35 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 79
    Questions
  • 42
    Replies
I am trying to update a contact based on accout Code not a account name (field of contact). this Account code is available in Account.
When i create a new contact i will give a account code , at that time account name need to update based on this account code only...

Here is the following Code, can you please give me a proper trigger for this process

********************************************************************************
trigger ContactMapToAccount on Contact (before insert , before update) {
     
    //Set Of Id In Contact Code & Id
    Set<Id> conId = New Set<Id>();
    Set<Id> conCode = New Set<Id>();
    for(Contact c : Trigger.New){
        conId.add(c.Id);
        
    }
    
    List<Contact> lstCont = [Select id, Account_Code__c, name from Contact Where ID IN :conId];
    Map<Id,Account> acMap = new Map<Id,Account>();
    for(Account a : lstCont){
        acMap.put(a.id, a);
        
    }
    
    for(Contact c : lstCont){
        
        c.Account_Code__c = acMap.get(a.Account_Code__c);
    }
}


**************************

Thnaks in advance
Hi I am going to diaply the more than records with action like edit and remove.

When i have click the edit commandlink button that row only allow to able to modify. suppose i have to click the third row edit commandlink button that row only allow to able to modify. If any know reply me.

i have attached my sample screen shot.User-added image

 
public class sparedetails
{
    public Spare_Details__c sparedet{get;set;}
    public String sparedetail {get;set;}
    public String asparedetail {get;set;}
    public Boolean check{get;set;}
    public Boolean pcheck{get;set;}
    public Engineer_Checklist__c ec{get;set;}
    public List<sparts> ssList{get;set;}    
    
    public class sparts{
        public List<SelectOption> sdetail{get;set;}
        public List<selectOption> sdetaildep{get;set;}
        public integer qty{get;set;}
        public String aparts{get;set;}
        public sparts(){
            this.sdetail=sdetails();  // Here how to call, i have call this type error in "Invalid Field"
            this.sdetaildep=getasparedetails(); // Same as here
            this.qty=0;
            this.aparts='';
        }
    }
    
    public sparedetails(ApexPages.StandardController controller) {
    check=false;
    pcheck=false;
    //ec=[select id,Engineer__r.name from Engineer_Checklist__c where id=:apexpages.currentpage().getparameters().get('id')];
    //sparedet = [select aspareparts__c,qty__c,spareparts__c,sparepartsinp__c from Spare_Details__c where id=:apexpages.currentpage().getparameters().get('id')];
    ssList=new List<sparts>();
    }
    
    public PageReference addrow(){
             
        ssList.add(new sparts());
        return null;
    }
    public void removeRow(){
        Integer count=Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
        ssList.remove(count);
    }
    
    public List<SelectOption> sdetails()
    {
        List<SelectOption> spd = new List<SelectOption>();
        
        spd.add(new SelectOption('None','--- None ---')); 
        spd.add(new SelectOption('sd','Smoke Detector')); 
        spd.add(new SelectOption('hd','Heat Detector')); 
        spd.add(new SelectOption('msd','Multi Sensor Detector')); 
        spd.add(new SelectOption('bs','Base')); 
        spd.add(new SelectOption('ss','Smoke Sounder')); 
        spd.add(new SelectOption('hs','Heat Sounder')); 
        spd.add(new SelectOption('bc','Breakglass Callpoint')); 
        spd.add(new SelectOption('tk','Test Keys')); 
        spd.add(new SelectOption('rg','Replacement Glass')); 
        spd.add(new SelectOption('bc','Breakglass Cover')); 
        spd.add(new SelectOption('es','Electronic Sounder')); 
        spd.add(new SelectOption('fb','Fire Bell')); 
        spd.add(new SelectOption('bec','Beacon')); 
        spd.add(new SelectOption('dr','Door Release')); 
        spd.add(new SelectOption('pc','Printer Consumables')); 
        spd.add(new SelectOption('slab','SLA Battery')); 
        spd.add(new SelectOption('nic','Nicad Hi-Temp Cells X'));
        spd.add(new SelectOption('anic','Additional Nicad Hi-Temp Cells X'));
        spd.add(new SelectOption('el','Emergency Lights'));
        spd.add(new SelectOption('ael','Additional Emergency Lights'));
        spd.add(new SelectOption('elt','EL Tube'));
        spd.add(new SelectOption('aelt','Additional EL Tube'));
        spd.add(new SelectOption('ftt','4,6,8FT Tube'));
        spd.add(new SelectOption('lbs','Log Book Supplied - Qty'));
        spd.add(new SelectOption('oth','Other'));        
        return spd;  
    } 
    
    public List<SelectOption> getasparedetails()
    {
        List<SelectOption> spdl = new List<SelectOption>();   
        
        if(sparedetail  == 'None'){
        check=false;
        }
         
        if(sparedetail  == 'sd' || sparedetail  == 'hd' || sparedetail  == 'ss' || sparedetail  == 'hs' || sparedetail  == 'es' || sparedetail  == 'bec'){
        
        pcheck=true;
        
            spdl.add(new SelectOption('at','ADT'));
            spdl.add(new SelectOption('ad','Apollo Discovery'));
            spdl.add(new SelectOption('as65','Apollo S65'));
            spdl.add(new SelectOption('ax95','Apollo XP95'));
            spdl.add(new SelectOption('aut','Autronica'));
            spdl.add(new SelectOption('ed','EDA'));
            spdl.add(new SelectOption('em','EMS'));
            spdl.add(new SelectOption('get','Gent'));
            spdl.add(new SelectOption('hoc','Hochiki'));
            spdl.add(new SelectOption('nitt','Nittan'));
            spdl.add(new SelectOption('not','Notifier'));
            spdl.add(new SelectOption('men','Menvier'));
            spdl.add(new SelectOption('pro','Protec'));
            spdl.add(new SelectOption('raf','Rafiki'));
            spdl.add(new SelectOption('sys','Systemsensor'));
            spdl.add(new SelectOption('zit','Ziton'));
            spdl.add(new SelectOption('oth','Other'));
        }        
        if(sparedetail  == 'msd'){
        }        
        if(sparedetail  == 'bs'){        
        pcheck=true;
            spdl.add(new SelectOption('db','Detector Base'));
            spdl.add(new SelectOption('dob','Diode Base'));
        }        
        if(sparedetail  == 'bc'){   
        pcheck=true;     
            spdl.add(new SelectOption('at','ADT'));
            spdl.add(new SelectOption('ad','Apollo Discovery'));
            spdl.add(new SelectOption('as65','Apollo S65'));
            spdl.add(new SelectOption('ax95','Apollo XP95'));
            spdl.add(new SelectOption('aut','Autronica'));
            spdl.add(new SelectOption('ed','EDA'));
            spdl.add(new SelectOption('em','EMS'));
            spdl.add(new SelectOption('get','Gent'));
            spdl.add(new SelectOption('hoc','Hochiki'));
            spdl.add(new SelectOption('nitt','Nittan'));
            spdl.add(new SelectOption('not','Notifier'));
            spdl.add(new SelectOption('men','Menvier'));
            spdl.add(new SelectOption('pro','Protec'));
            spdl.add(new SelectOption('raf','Rafiki'));
            spdl.add(new SelectOption('sys','Systemsensor'));
            spdl.add(new SelectOption('zit','Ziton'));
            spdl.add(new SelectOption('wp','Waterproof'));
            spdl.add(new SelectOption('oth','Other'));
        }        
        if(sparedetail  == 'tk' || sparedetail  == 'rg' || sparedetail  == 'bc' || sparedetail  == 'fb' || sparedetail  == 'dr' || sparedetail  == 'pc' || sparedetail  == 'ftt' || sparedetail  == 'lbs' || sparedetail  == 'oth'){
            check = true;
            pcheck=false;
        }        
        if(sparedetail  == 'slab'){
        pcheck=true;        
            spdl.add(new SelectOption('1.2a','12v 1.2Ah'));
            spdl.add(new SelectOption('12a','12v 12Ah'));
            spdl.add(new SelectOption('17a','12v 17Ah'));
            spdl.add(new SelectOption('2.1a','12v 2.1Ah'));
            spdl.add(new SelectOption('2.8a','12v 2.8Ah'));
            spdl.add(new SelectOption('24a','12v 24Ah'));
            spdl.add(new SelectOption('3.2a','12v 3.2Ah'));
            spdl.add(new SelectOption('7a','12v 7Ah'));
            spdl.add(new SelectOption('10a','6v 10Ah'));
            spdl.add(new SelectOption('ed','EDA'));
            spdl.add(new SelectOption('es','EMS'));
        }        
        if(sparedetail  == 'nic' || sparedetail  == 'anic'){     
        pcheck=true;   
            spdl.add(new SelectOption('1c','1 Cell'));
            spdl.add(new SelectOption('2c','2 Cell'));
            spdl.add(new SelectOption('3c','3 Cell'));
            spdl.add(new SelectOption('4c','4 Cell'));
            spdl.add(new SelectOption('5c','5 Cell'));
            spdl.add(new SelectOption('oth','Other'));
        }        
        if(sparedetail  == 'el' || sparedetail  == 'ael'){  
        pcheck=true;      
            spdl.add(new SelectOption('16w','16w 2D'));
            spdl.add(new SelectOption('28w','28w 2D'));
            spdl.add(new SelectOption('38w','38w 2D'));
            spdl.add(new SelectOption('2d','28w 2D c/w P/c'));
            spdl.add(new SelectOption('8w','8w Bulkhead'));
            spdl.add(new SelectOption('eb','Exit Box'));
            spdl.add(new SelectOption('ld','LED'));
            spdl.add(new SelectOption('ldb','LED Bulkhead'));
            spdl.add(new SelectOption('leb','LED Exit box'));
            spdl.add(new SelectOption('lgd','Legend'));
            spdl.add(new SelectOption('tb','Twinspot Beam'));
        }        
        if(sparedetail  == 'elt' || sparedetail  == 'aelt'){   
        pcheck=true;     
            spdl.add(new SelectOption('4w','4 Watt Tube rep.'));
            spdl.add(new SelectOption('6w','6 Watt Tube rep.'));
            spdl.add(new SelectOption('8w','8 Watt Tube rep.'));
            spdl.add(new SelectOption('2d','2D Lamp/Biax'));
        }    
          
        return spdl;
    }       
}


Here how to call my picklist method in wrapper class.
 
MY VF PAGE:

<apex:page standardController="Engineer_Checklist__c" extensions="sparedetail">
    
    <apex:form >
    
    <apex:pageBlock >
    
    
        <apex:pageBlockSection columns="5" title="Spare Details">
        
            <apex:pageblockSectionItem > 
                         
                <apex:selectList size="1" multiselect="false" value="{!selspare}">
                    <apex:selectOptions value="{!Spare}"/>
                    <apex:actionSupport event="onchange" reRender="a"/>
                </apex:selectList>   
                         
            </apex:pageblockSectionItem>
                      
            <apex:pageblockSectionItem >
                <apex:selectList size="1" multiselect="false" value="{!sparedetails}" id="a">
                    <apex:selectOptions value="{!sparedetails}"/>
                </apex:selectList>
            </apex:pageblockSectionItem> 
             <apex:inputField value="{!sparedet.sparepartsinp__c}" rendered="{!check}"/>
             <apex:inputField label="QTY" value="{!sparedet.qty__c}"/> 
                                 
        </apex:pageBlockSection>        
    </apex:pageBlock>

    </apex:form>

</apex:page>

My Controller:

public with sharing class sparedetail {

    public Spare_Details__c sparedet{get;set;}
    public boolean check{get;set;}
    public String selspare{get;set;}
    public List<SelectOption> Spare{get;set;}
    public List<SelectOption> sparedetail {get;set;}
    public List<SelectOption> sparedetails{get;set;}
    public Engineer_Checklist__c ec{get;set;}
    

    public sparedetail(ApexPages.StandardController controller) {
    check =false;
    
    //sparedet = [select spareparts__c,aspareparts__c,sparepartsinp__c,qty__c from Spare_Details__c where id=:apexpages.currentpage().getparameters().get('id')];
    ec=[select id,Engineer__r.name from Engineer_Checklist__c where id=:apexpages.currentpage().getparameters().get('id')];
        Spare=Spares();
        
    }

    
    public PageReference addrow(){
        //sparedet.add(new Spare_Details__c(service_sheet__c=ec.id));
        return null;
    }
    
    public List<SelectOption> Spares() {
    
        List<SelectOption> spd = new List<SelectOption>();
        
        spd.add(new SelectOption('None','--- None ---')); 
        spd.add(new SelectOption('sd','Smoke Detector')); 
        spd.add(new SelectOption('hd','Heat Detector')); 
        spd.add(new SelectOption('msd','Multi Sensor Detector')); 
        spd.add(new SelectOption('bs','Base')); 
        spd.add(new SelectOption('ss','Smoke Sounder')); 
        spd.add(new SelectOption('hs','Heat Sounder')); 
        spd.add(new SelectOption('bc','Breakglass Callpoint')); 
        spd.add(new SelectOption('tk','Test Keys')); 
        spd.add(new SelectOption('rg','Replacement Glass')); 
        spd.add(new SelectOption('bc','Breakglass Cover')); 
        spd.add(new SelectOption('es','Electronic Sounder')); 
        spd.add(new SelectOption('fb','Fire Bell')); 
        spd.add(new SelectOption('bec','Beacon')); 
        spd.add(new SelectOption('dr','Door Release')); 
        spd.add(new SelectOption('pc','Printer Consumables')); 
        spd.add(new SelectOption('slab','SLA Battery')); 
        spd.add(new SelectOption('nic','Nicad Hi-Temp Cells X'));
        spd.add(new SelectOption('anic','Additional Nicad Hi-Temp Cells X'));
        spd.add(new SelectOption('el','Emergency Lights'));
        spd.add(new SelectOption('ael','Additional Emergency Lights'));
        spd.add(new SelectOption('elt','EL Tube'));
        spd.add(new SelectOption('aelt','Additional EL Tube'));
        spd.add(new SelectOption('ftt','4,6,8FT Tube'));
        spd.add(new SelectOption('lbs','Log Book Supplied - Qty'));
        spd.add(new SelectOption('oth','Other'));
        
        return spd;  
    }
    
    public List<SelectOption> sparedetails(){
    
    List<SelectOption> spdl = new List<SelectOption>();
    
    if(selspare == 'sd' || selspare == 'hd' || selspare == 'ss' || selspare == 'hs' || selspare == 'es' || selspare == 'bec'){
    
    spdl.add(new SelectOption('at','ADT'));
    spdl.add(new SelectOption('ad','Apollo Discovery'));
    spdl.add(new SelectOption('as65','Apollo S65'));
    spdl.add(new SelectOption('ax95','Apollo XP95'));
    spdl.add(new SelectOption('aut','Autronica'));
    spdl.add(new SelectOption('ed','EDA'));
    spdl.add(new SelectOption('em','EMS'));
    spdl.add(new SelectOption('get','Gent'));
    spdl.add(new SelectOption('hoc','Hochiki'));
    spdl.add(new SelectOption('nitt','Nittan'));
    spdl.add(new SelectOption('not','Notifier'));
    spdl.add(new SelectOption('men','Menvier'));
    spdl.add(new SelectOption('pro','Protec'));
    spdl.add(new SelectOption('raf','Rafiki'));
    spdl.add(new SelectOption('sys','Systemsensor'));
    spdl.add(new SelectOption('zit','Ziton'));
    spdl.add(new SelectOption('oth','Other'));
    }
    
    if(selspare == 'msd'){
    }
    
    if(selspare == 'bs'){
    
    spdl.add(new SelectOption('db','Detector Base'));
    spdl.add(new SelectOption('dob','Diode Base'));
    }
    
    if(selspare == 'bc'){
    
    spdl.add(new SelectOption('at','ADT'));
    spdl.add(new SelectOption('ad','Apollo Discovery'));
    spdl.add(new SelectOption('as65','Apollo S65'));
    spdl.add(new SelectOption('ax95','Apollo XP95'));
    spdl.add(new SelectOption('aut','Autronica'));
    spdl.add(new SelectOption('ed','EDA'));
    spdl.add(new SelectOption('em','EMS'));
    spdl.add(new SelectOption('get','Gent'));
    spdl.add(new SelectOption('hoc','Hochiki'));
    spdl.add(new SelectOption('nitt','Nittan'));
    spdl.add(new SelectOption('not','Notifier'));
    spdl.add(new SelectOption('men','Menvier'));
    spdl.add(new SelectOption('pro','Protec'));
    spdl.add(new SelectOption('raf','Rafiki'));
    spdl.add(new SelectOption('sys','Systemsensor'));
    spdl.add(new SelectOption('zit','Ziton'));
    spdl.add(new SelectOption('wp','Waterproof'));
    spdl.add(new SelectOption('oth','Other'));
    }
    
    if(selspare == 'tk' || selspare == 'rg' || selspare == 'bc' || selspare == 'fb' || selspare == 'dr' || selspare == 'pc' || selspare == 'ftt' || selspare == 'lbs' || selspare == 'oth'){
    check = true;
    }
    
    if(selspare == 'slab'){
    
    spdl.add(new SelectOption('1.2a','12v 1.2Ah'));
    spdl.add(new SelectOption('12a','12v 12Ah'));
    spdl.add(new SelectOption('17a','12v 17Ah'));
    spdl.add(new SelectOption('2.1a','12v 2.1Ah'));
    spdl.add(new SelectOption('2.8a','12v 2.8Ah'));
    spdl.add(new SelectOption('24a','12v 24Ah'));
    spdl.add(new SelectOption('3.2a','12v 3.2Ah'));
    spdl.add(new SelectOption('7a','12v 7Ah'));
    spdl.add(new SelectOption('10a','6v 10Ah'));
    spdl.add(new SelectOption('ed','EDA'));
    spdl.add(new SelectOption('es','EMS'));
    }
    
    if(selspare == 'nic' || selspare == 'anic'){
    
    spdl.add(new SelectOption('1c','1 Cell'));
    spdl.add(new SelectOption('2c','2 Cell'));
    spdl.add(new SelectOption('3c','3 Cell'));
    spdl.add(new SelectOption('4c','4 Cell'));
    spdl.add(new SelectOption('5c','5 Cell'));
    spdl.add(new SelectOption('oth','Other'));
    }
    
    if(selspare == 'el' || selspare == 'ael'){
    
    spdl.add(new SelectOption('16w','16w 2D'));
    spdl.add(new SelectOption('28w','28w 2D'));
    spdl.add(new SelectOption('38w','38w 2D'));
    spdl.add(new SelectOption('2d','28w 2D c/w P/c'));
    spdl.add(new SelectOption('8w','8w Bulkhead'));
    spdl.add(new SelectOption('eb','Exit Box'));
    spdl.add(new SelectOption('ld','LED'));
    spdl.add(new SelectOption('ldb','LED Bulkhead'));
    spdl.add(new SelectOption('leb','LED Exit box'));
    spdl.add(new SelectOption('lgd','Legend'));
    spdl.add(new SelectOption('tb','Twinspot Beam'));
    }
    
    if(selspare == 'elt' || selspare == 'aelt'){
    
    spdl.add(new SelectOption('4w','4 Watt Tube rep.'));
    spdl.add(new SelectOption('6w','6 Watt Tube rep.'));
    spdl.add(new SelectOption('8w','8 Watt Tube rep.'));
    spdl.add(new SelectOption('2d','2D Lamp/Biax'));
    }
    
 return spdl;
    }
    
 }

Hello I have to like create a dependency picklist in vf page. But my first picklist value has been displayed. But when i have to change first picklist the second picklist not changed and also not displayed. IF anyone know please let me.
<apex:page >   
    <apex:includeScript value="{!URLFOR($Resource.dateformat)}" />
    <apex:includeScript id="a" value="https://www.google.com/jsapi" />  
    
    <apex:sectionHeader subtitle="Reactive Call Outs Per Day"/>
    <!-- Google Charts will be drawn in this DIV -->
    <div id="chart_div" />
   
    <script type="text/javascript" src="/soap/ajax/20.0/connection.js"></script>
    <script type="text/javascript">
    
        sforce.connection.sessionId  = "{!$Api.Session_ID}";
        var result = sforce.connection.query("SELECT DAY_ONLY(CreatedDate) days, count(createdDate) counts FROM Visits__c where createdDate = LAST_N_Days:90 AND Cancelled__c = false AND Visit_Type__c = 'Reactive' AND (Call_Out_Types__c = 'Call Out' OR Call_Out_Types__c = 'Revisit' OR Call_Out_Types__c = 'Recall' OR Call_Out_Types__c = 'Revisit - P&L Only') AND (NOT(Site__r.Name = 'Messages' OR Site__r.Name = 'Holidays' OR Site__r.Name = 'Projects Work' OR Site__r.Name = 'Training' OR Site__r.Name = 'Unifier Test Customer' OR Site__r.Name = 'Unifier Test Customer - Site A' OR Site__r.Name = 'Unifier Test Customer - Site B' OR Site__r.Name = 'Unifier Test Customer - Site C' OR Site__r.Name = 'Unifier Test Customer - Site D')) GROUP BY DAY_ONLY(CreatedDate) order by DAY_ONLY(createdDate) desc");
        
        records = result.getArray("records");
        
        // Load the Visualization API and the piechart package.
        google.load('visualization', '1.0', {'packages':['corechart']});
        google.load("visualization", "1", {packages: ["scatter"]});
        
        google.setOnLoadCallback(drawCharts);
        
        function drawCharts() {         
            var data = new google.visualization.DataTable(); 
            
            data.addColumn('string', 'Created Date');
            data.addColumn('number', 'Record Count');
            data.addRows(records.length);
            
            for(var i = 0 ; i < records.length ; i++){
                       
           var dateformat = moment(records[i].days).format("DD-MM-YYYY");
              
                data.setValue(i,0,dateformat);
                data.setValue(i,1,records[i].counts);
            }
            
            var options = {
                title: '',
                hAxis: {title: 'Created Date'},
                vAxis: {title: 'counts'},
                legend: 'none',
                trendlines: { 0: {color: 'green',} }    // Draw a trendline for data series 0.
              };
        
        var visualization = new google.visualization.ColumnChart(document.getElementById('chart_div')); 
        visualization.draw(data, {showRowNumber: true, width: '1250', height: '500'}, options);
               
    }
    </script>
</apex:page>


IN this above code Trend Line is not showing chart. Why? anyone know reply.
<apex:page >

<apex:includeScript id="a" value="https://www.google.com/jsapi" />

<apex:sectionHeader subtitle="Reactive Call Outs Per Day"/>

<!-- Google Charts will be drawn in this DIV -->
<div id="chart_div" />

    <script type="text/javascript" src="/soap/ajax/29.0/apex.js"></script>
    <script type="text/javascript" src="/soap/ajax/20.0/connection.js"></script>
    <script type="text/javascript">

            var result = sforce.connection.query("SELECT DAY_ONLY(CreatedDate) days, count(createdDate) counts FROM Visits__c where createdDate = LAST_N_Days:90  GROUP BY DAY_ONLY(CreatedDate) order by DAY_ONLY(createdDate) desc");
            records = result.getArray("records");
            alert(records);
            
    
   // Load the Visualization API and the piechart package.
    google.load('visualization', '1.0', {'packages':['corechart']});
    
    google.setOnLoadCallback(drawCharts);

    function drawCharts() {         
     
           var data = new google.visualization.arrayToDataTable();
           
               data.addColumn('date', 'Created Date');
               data.addColumn('number', 'Record Count');
               
                              
             for(var i =0; i<records.length;i++)
                 data.Rows.add(['records[i].days', 'records[i].counts']);
                   
                 
                 var options = {
                title: '',
                hAxis: {title: 'days'},
                vAxis: {title: 'counts'},
                legend: 'none',
                trendlines: { 0: {color: 'red',} }    // Draw a trendline for data series 0.
              };   
               
          var visualization = new google.visualization.ColumnChart(document.getElementById('chart_div'));  
              
          visualization.draw(data,options);
          
           
          
      }
</script>
</apex:page>


In this above code Query working correctly. But Chart is not displayed Why?.......
Hi All,
          I have create a button in Account standard page as "Save as PDF". When i have to click that button to save the current Account standard page save as pdf. If any know how to save Standard page as PDF.
Hello,

Any one know how to create a trend line report in visualforce page. Or if anyone know how to implement the jqwidgets in visualforce page report.

http://www.jqwidgets.com/blog/
List<Decimal> cal =new List<Decimal>();
public decimal fun(){
cal.add(0.0);
cal.add(0.1);
return cal;  // This is possible, But when I have to return that time to display error: "Return value must be of type: Decimal at line"
}

If any one know how to return the list decimal value into function.
I would like to create a report for trend line in below report for salesforce. Then How to do create the Trend Line report for report tab in salesforce

I want to create the trend line report for above report images How?
My old value does not come, only display new map value why. how can i get old map value in apex trigger
I want crate contract tab. That tab containts many records name as visit. How to get all record value when the same contract id visit value in apex class.
I have like to compare previous lookup field value and current lookup field value. If it is same value record is saved, otherwise throw error message.
How to get previous stored lookup value in lookupfield.
I have install the "twilio" api in salesforce and I have register twilio phone number. How to receive the SMS details and how revert back the conformation.Which class should be call and where should I give the accoutsid,authosid and twilio phone number in Installed Package from Sandbox .