+ Start a Discussion
iyappan kandasamy 4iyappan kandasamy 4 

general apex code

how to fetch approver name from approver id in salesforce apex class
In my requirement for the case object...there is 'approval history'...in that I want the 'actual approver' name in my apex class. For this i have written the apex extension class...and in my visual force page i have to stamp this value....

Apex extension class:
-----------------------------
public with sharing class gkrefundrequest
 {
  public Id caseId {get;set;}
  public case caserecord {get;set;}
  public String approver{get;set;}  
  public list<ProcessInstance> lista{get;set;}

  
  public gkrefundrequest(ApexPages.standardController stdController)
  {
  this.caseId = stdController.getId();          //The stdcontroller will get the case record id
  lista = new list<ProcessInstance>();
  lista = [SELECT LastActor.name,TargetObjectId, SubmittedById FROM ProcessInstance WHERE TargetObjectId = '50058000005fGYz' and status='approved']; // for that particualar case this query will fetch approver id
  }  
  }

My visual for page where to stamp the 'actual approver' value is:
------------------------------------------------------------------------------------
<tr>
                    <td><b>Sales Approval:</b></td>
                    <td>{!case.caseid }</td>
                </tr>
                

but the above thing is not working....only im getting the actual approver id....not the actual approver name....

Please kindly need help on the above as it is very very urgent...I have to submit tomorrow...
Thanks in advance...
Raj VakatiRaj Vakati
Change like below 
 
public with sharing class gkrefundrequest
 {
  public Id caseId {get;set;}
  public case caserecord {get;set;}
  public String approver{get;set;}  
  public list<ProcessInstance> lista{get;set;}

  
  public gkrefundrequest(ApexPages.standardController stdController)
  {
  this.caseId = stdController.getId();          //The stdcontroller will get the case record id
  lista = new list<ProcessInstance>();
  lista = [SELECT LastActorId, LastActor.Name ,TargetObjectId, SubmittedById FROM ProcessInstance WHERE TargetObjectId = '50058000005fGYz' and status='approved']; // for that particualar case this query will fetch approver id
  }  
  }

in page 
 
<tr>
                    <td><b>Sales Approval:</b></td>
                    <td>{!lista[0].LastActor.Name }</td>
                </tr>