0

I have an approval process which approves records based on some criteria in opportunity object. So I designed a visualforce component having a controller and I called the component in visualforce email template. I just want to know how to get the approver name in the component so that it will be displayed in the initial submission of approval process. Any help will be appreciated. The code looks like this: The controller code

public class oppor_recs
{
    public List opList{get;set;} 
    public List getOpportunity()
    { 
        opList=[SELECT Name,StageName,Amount,CloseDate 
                FROM opportunity 
                WHERE Amount > 50000 AND CreatedDate=:Date.Today() 
                LIMIT 10000];
        return opList;
    }
}

visualforce component

<apex:column value="{!opp.name}">
  <apex:facet name="header">Name</apex:facet>
</apex:column>
  • You can get approver name by current user like ($User.FirstName)+" "+($User.LastName) – Pavan tej Oct 6 '16 at 15:07
  • @Pavan, I tried its not working – Krishna Casukhela Oct 7 '16 at 3:16
1

I think you might be wanting to use the ProcessInstance object in your code. It has a child relationship to Opportunity, which should enable to you get the approver name.

In your query, you could try something like this:

opList=[SELECT Name,StageName,Amount,CloseDate,
            (SELECT Id, LastActor.Name FROM ProcessInstances)
        FROM Opportunity 
        WHERE Amount > 50000 AND CreatedDate=:Date.Today() 
        LIMIT 10000];

You may want to do some post processing before rendering to the page, but I think this will work for you.

  • ProcessInstance gives only ID of user who approved and not the name so how to get the approvername.Pls suggest. – Krishna Casukhela Oct 7 '16 at 3:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.