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
Cool_DevloperCool_Devloper 

Approval History Related List in Custom VF Screen

Hello VF Gurus,

I have created a Custom VF Screen with a Custom Controller.

The issue is that i am unable to show the Approval History related list on the Custom Screen, even though i am using the below code:

<apex:relatedList list="ProcessSteps" ></apex:relatedList>

Can someone please let me know what is that i am missing out here. Seems to be a very simple thing to do ... somehow still stuck :(

Any help will be very useful!!

Thanks,

Cool_D

P.S: I have already created an Approval Process for the Custom Object.

Ron HessRon Hess
there are a very few related lists that present a challenge to display, the solution is something like this

Code:
<apex:pageBlockTable value="{!histories}" var="h">
                <apex:column headerValue="Date"  value="{!h.historyDate}"/>
                <apex:column headerValue="Public">
                    <apex:image value="{!URLFOR($Resource.images_checkbox, IF(h.ispublic, 'true.gif','false.gif'))}"/>
                </apex:column>
                <apex:column headerValue="Who"  value="{!h.actorname}"/>
                <apex:column headerValue="What" value="{!h.historyType}"/>
                <apex:column headerValue="From" value="{!h.fr}"/>
                <apex:column headerValue="To"   value="{!h.to}"/>
            </apex:pageBlockTable>

 
the histories list is an apex wrapper class , you may not need that, but you will need a repeat or pageblocktable, pass the object.related list as the list to repeat over, then display columns that format as you require.

it's a bit more work than a normal related list, but it works.
Cool_DevloperCool_Devloper

Thanks for the reply Ron.

What i understand from your post is that, i can build my apex class and fetch the list of related records from it and display them as a related list.

But in my case, i want to display the "Approval History" as the related list. Will this workaround work in this case as well? How can i fetch those records, basically Approval Actions/Steps?

Moreover, i want to achieve the standard functionality of Salesforce Approval Process, giving the users, the option of submitting a record for approval and then the process is kicked off. (As it happens in the Standard Approval History Related List)

Is this possible? I am dead if this does'nt work :(

Thanks



Message Edited by Cool_Devloper on 12-28-2008 07:46 PM
Ron HessRon Hess
you won't need to build the apex class, you can pass the approval history related list into a repeat tag or page block table tag

you do have to construct / specify the columns that will appear, these would not be user configurable.

i believe you can add a simple button that begins the approval process, but i haven't tried this myself.
Cool_DevloperCool_Devloper

Hello Ron,

Thanks a ton for your useful answers.

I tried doing as per what you suggested. Unfortunately, landed into this exception:

"System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Plan__c.ProcessSteps"

I really am not able to figure out this issue. "Plan__c" is my cutom object.

Need help again :(

thanks

Cool_DevloperCool_Devloper

Hello Ron,

I was able to add the Approval History related list through "Controller Extension".

The issue now is that, for each event like submit, recall of that record to the approver, i am being redirected to the standard salesforce page but i want to redirect to my custom VF screen only.

Can you please let me know if there is way i can over-ride this standard functionality either through apex or through some other way?

Thanks in Advance....

Ron HessRon Hess
you may be able to set the  return URL before calling the submit page, this would be retURL=your vf page

you may have to url encode your retURL


Cool_DevloperCool_Devloper

But Ron,

How can i set the retURL as i dont know from where can i override the submit button. It is a part of the standard Approval process.

Is there a way to do so?

Thanks,

Cool_D

Pooja05Pooja05

How did you add the approval history related list through the controller extension class?

 

I copied the VF code from the post, however I need a getHistories method in the the apex class. I am not sure what will be the return type of this method

 

 

Thanks,
Pooja

Pooja05Pooja05

Got it.

 

List<Quote__History> histories = select .....

 

I missed the two underscores..I kept trying Quote_History.

 

 

Thanks,

Pooja

Cool_DevloperCool_Devloper

Pooja,

 

You can get these related list directly giving the Subject parameter in the related list component.

 

Anyways, good it worked for you!!

 

Cool_D

ChellappaChellappa

Hi ,

 

I have a slightly different problem.

 

We have a custom object where by Role Hierarchy , the logged in User has no access to record.

But using VF pages, i am bringing the records and displaying it.

I am able to list all the fields and the Non Access User is able to update the data also .

 

But now the main question, i tried using the point which you just mentioned.

 

 <apex:relatedList list="ProcessSteps" subject="{!$CurrentPage.parameters.Id}" />

 

If i do this, the record is following ownership access logic.

The page says Insufficient Privileges. 

Is there any way we can use the Data List or PageBlock in VF page for approval history also even though the user has no Record Level access..