function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sp13sp13 

Items To Approve in visualforce page

is it possible to put the Items to Approve component from Home Tab to a visualforce page? how?
Vinita_SFDCVinita_SFDC
Hi,

You can create a custom button for apporoval and place it on VF. Please refer following links for sample code:

http://sfdc.arrowpointe.com/2009/01/08/invoke-apex-from-a-custom-button-using-a-visualforce-page/

http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#CSHID=apex_process_example.htm|StartTopic=Content%2Fapex_process_example.htm|SkinName=webhelp
Brian GlassBrian Glass
Does anyone have an answer for how or if this can be done?  The above reply did not address the question.
Sukhpreet Lotey 6Sukhpreet Lotey 6
Looking for the same answer
Mark GuildayMark Guilday
If anyone actually has some source code or an app that can actually answer the question I'd love to hear. Thanks
jaw999jaw999
Your query code will be like:
 
public UsersItemsToApprove (ApexPages.StandardController controller) {

    }


       public List<ProcessInstanceWorkitem> getWorkItems() {
        List<ProcessInstanceWorkitem> results = new List<ProcessInstanceWorkitem>();
        List<ProcessInstanceWorkitem> allitems = [SELECT ElapsedTimeInDays, originalActor.name, processInstance.targetObjectId,
               ProcessInstance.TargetObject.name, processInstance.status, processinstance.ProcessDefinition.name,
               ProcessInstance.CreatedDate
               
                FROM ProcessInstanceWorkitem
                WHERE ActorId= :UserInfo.getUserId()
                AND
                processInstance.status =: 'Pending'];
      
      
        for(ProcessInstanceWorkitem thisitem : allitems)
      
      
      
        {
           
                results.add(thisitem);
                      
        }
        return results;
    }




and to put in a table in your page you run something like:
 
<apex:pageBlock title="Items to Approve" > 
 <apex:pageBlockTable value="{!WorkItems}" var="c" id="items" > 

 
<apex:column headerValue="Item"><apex:outputLink value="/{!c.ProcessInstance.TargetObject.id}" target="_blank">{!c.ProcessInstance.TargetObject.name}</apex:outputLink></apex:column> 
<apex:column headerValue="Submitted by" value="{!c.originalActor.name}"/>
<apex:column headerValue="Process" value="{!c.processinstance.ProcessDefinition.name}"/>
<apex:column headerValue="Status" value="{!c.processInstance.status}"/>
<apex:column headerValue="Started Date" value="{!c.ProcessINstance.CreatedDate}"/>

</apex:pageBlockTable> 
</apex:pageBlock>