You need to sign in to do that
Don't have an account?
Adriana Voyce
Apex Class Approval Processes ActorID, OriginalActorid, and SystemModstamp to display names and Est - and adjust Controller columns
Hi All,
Please keep your responses as simple as possible, I am learning :)
I created A Class, A controller, and a VF template to display the approval process details, however... The values returned are UserIDs and GMT time stamp - Additionally I can't seem to get a nice table in my visualforce template it doesn't seem to respect the percentages I give it or setting it to 100%. Image of wants below along with my code.
I assume I need to tell my class to give me the Actorname but thats not one of the values I can pull from = getApprovalSteps not sure how to accomplsih this or do I do this somwhere else?
Class:
public class OpportunityApprovalHistoryController {
public String opptyId {get;set;}
public List<ProcessInstanceHistory> getApprovalSteps()
{if (opptyId != null) {Opportunity quote =
[Select Id,
(Select TargetObjectId, SystemModstamp, StepStatus, RemindersSent, ProcessInstanceId, OriginalActorId, IsPending,
IsDeleted, Id, CreatedDate, CreatedById, Comments, ActorId From ProcessSteps order by SystemModstamp desc)
from Opportunity where Id = :opptyId];
return quote.ProcessSteps;}
return new List<ProcessInstanceHistory> ();}}
Controller:
<apex:component controller="OpportunityApprovalHistoryController" access="global">
<apex:attribute name="oppId" assignTo="{!opptyId}" type="String" description="Id of the opportunity"/>
<apex:dataTable value="{!approvalSteps}" var="step">
<style></style>
<apex:facet name="caption">Approval History</apex:facet>
<apex:facet name="header">Details</apex:facet>
<apex:column width="20%">
<apex:facet name="header">Date</apex:facet>
<apex:outputText value="{!step.SystemModstamp}"/>
</apex:column>
<apex:column width="20%">
<apex:facet name="header">Status</apex:facet>
<apex:outputText value="{!step.StepStatus}"/>
</apex:column>
<apex:column width="20%" >
<apex:facet name="header">Assigned To</apex:facet>
<apex:outputText value="{!step.OriginalActorid}"/>
</apex:column>
<apex:column width="20%">
<apex:facet name="header">Actual Approver</apex:facet>
<apex:outputText value="{!step.ActorID}"/>
</apex:column>
<apex:column width="20%">
<apex:facet name="header">Comments</apex:facet>
<apex:outputText value="{!step.Comments}"/>
</apex:column>
</apex:dataTable>
</apex:component>
VF Template
<messaging:emailTemplate subject="Opportunity {!relatedTo.Name} Submitted for {!relatedTo.Subscription_Discount_Percent__c}% Subscription Discount" recipientType="User" relatedToType="Opportunity">
<messaging:HtmlEmailBody >
<p>Hello {!recipient.Name},</p>
<p>Opportunity: {!relatedTo.Name} for {!relatedTo.Account.Name} has been submitted for approval: </p>
<html>
<head>
<meta content="text/css;charset=utf-8" http-equiv="Content-Type"/>
<meta name="Template" content="Response"/>
</head>
<body>
<p><b>Approval History</b>
<c:opportunityapprovalhistory oppId="{!relatedTo.Id}" />
</p>
</body>
</html>
</messaging:HtmlEmailBody>
</messaging:emailTemplate>
WHAT I WANT
User full name not ID; Date in this format 5/16/2017 Est, and columns that auto size to the text along with borders on the table.
Please keep your responses as simple as possible, I am learning :)
I created A Class, A controller, and a VF template to display the approval process details, however... The values returned are UserIDs and GMT time stamp - Additionally I can't seem to get a nice table in my visualforce template it doesn't seem to respect the percentages I give it or setting it to 100%. Image of wants below along with my code.
I assume I need to tell my class to give me the Actorname but thats not one of the values I can pull from = getApprovalSteps not sure how to accomplsih this or do I do this somwhere else?
Class:
public class OpportunityApprovalHistoryController {
public String opptyId {get;set;}
public List<ProcessInstanceHistory> getApprovalSteps()
{if (opptyId != null) {Opportunity quote =
[Select Id,
(Select TargetObjectId, SystemModstamp, StepStatus, RemindersSent, ProcessInstanceId, OriginalActorId, IsPending,
IsDeleted, Id, CreatedDate, CreatedById, Comments, ActorId From ProcessSteps order by SystemModstamp desc)
from Opportunity where Id = :opptyId];
return quote.ProcessSteps;}
return new List<ProcessInstanceHistory> ();}}
Controller:
<apex:component controller="OpportunityApprovalHistoryController" access="global">
<apex:attribute name="oppId" assignTo="{!opptyId}" type="String" description="Id of the opportunity"/>
<apex:dataTable value="{!approvalSteps}" var="step">
<style></style>
<apex:facet name="caption">Approval History</apex:facet>
<apex:facet name="header">Details</apex:facet>
<apex:column width="20%">
<apex:facet name="header">Date</apex:facet>
<apex:outputText value="{!step.SystemModstamp}"/>
</apex:column>
<apex:column width="20%">
<apex:facet name="header">Status</apex:facet>
<apex:outputText value="{!step.StepStatus}"/>
</apex:column>
<apex:column width="20%" >
<apex:facet name="header">Assigned To</apex:facet>
<apex:outputText value="{!step.OriginalActorid}"/>
</apex:column>
<apex:column width="20%">
<apex:facet name="header">Actual Approver</apex:facet>
<apex:outputText value="{!step.ActorID}"/>
</apex:column>
<apex:column width="20%">
<apex:facet name="header">Comments</apex:facet>
<apex:outputText value="{!step.Comments}"/>
</apex:column>
</apex:dataTable>
</apex:component>
VF Template
<messaging:emailTemplate subject="Opportunity {!relatedTo.Name} Submitted for {!relatedTo.Subscription_Discount_Percent__c}% Subscription Discount" recipientType="User" relatedToType="Opportunity">
<messaging:HtmlEmailBody >
<p>Hello {!recipient.Name},</p>
<p>Opportunity: {!relatedTo.Name} for {!relatedTo.Account.Name} has been submitted for approval: </p>
<html>
<head>
<meta content="text/css;charset=utf-8" http-equiv="Content-Type"/>
<meta name="Template" content="Response"/>
</head>
<body>
<p><b>Approval History</b>
<c:opportunityapprovalhistory oppId="{!relatedTo.Id}" />
</p>
</body>
</html>
</messaging:HtmlEmailBody>
</messaging:emailTemplate>
WHAT I WANT
User full name not ID; Date in this format 5/16/2017 Est, and columns that auto size to the text along with borders on the table.
If you are getting Results in the Query Editor, Replace the Soql Query in Class as follows
Then, Change the Datatable Visualforce Markup.
Hope it Works, Mark this Solution a best Solution to Mark this thread as Solved.
Best,
Nithesh.
All Answers
To get a Good Table layout with borders, try PageBlockTable instead of DataTable.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_pageBlockTable.htm
To get User Name , Refer this Link
https://developer.salesforce.com/forums/?id=906F0000000BHqJIAW
For date format, I would do somethink Like this
Let me know if it works.
Best,
Nithesh
I have reviewed all of the links, but they did not work for me. When I try to use Pageblock I get errors same with the second link, pehaps I just don't know how to referwence it prperly in my class... Any ideas, or can you write the code of how to do this because I've been trying for days with no luck :( I will give the date a shot... Thanks!
Use Actor.Name instead of ActorId
<apex:column width="20%">
<apex:facet name="header">Date</apex:facet>
<apex:outputText value="{!step.SystemModstamp}"/>
<apex:outputText value="{0,date,MM/dd/yyyy}">
<apex:param value="{!step.SystemModstamp}"/>
</apex:outputText>
</apex:column>
The class should be:
public class OpportunityApprovalHistoryController {
public String opptyId {get;set;}
public List<ProcessInstanceHistory> getApprovalSteps()
{if (opptyId != null) {Opportunity quote =
[Select Id,
(Select TargetObjectId, SystemModstamp, StepStatus, RemindersSent, ProcessInstanceId, OriginalActorId, OriginalActor.name, IsPending,
IsDeleted, Id, CreatedDate, CreatedById, Comments, Actor.Name, ActorId From ProcessSteps order by SystemModstamp desc)
from Opportunity where Id = :opptyId];
return quote.ProcessSteps;}
return new List<ProcessInstanceHistory> ();}}
The controller Should be:
<apex:column width="20%" >
<apex:facet name="header">Assigned To</apex:facet>
<apex:outputText value="{!step.OriginalActor.name}"/>
</apex:column>
<apex:column width="20%">
<apex:facet name="header">Actual Approver</apex:facet>
<apex:outputText value="{!step.Actor.Name}"/>
</apex:column>
If you are getting Results in the Query Editor, Replace the Soql Query in Class as follows
Then, Change the Datatable Visualforce Markup.
Hope it Works, Mark this Solution a best Solution to Mark this thread as Solved.
Best,
Nithesh.