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
RDN_LHRRDN_LHR 

Mimic "Action" column for Visualforce Opportunity Line Items

Hi,

 

I'm experimenting with putting my own Visualforce page in for Opportunity Line Items related list.

 

To start with, I have this:

 

<apex:page standardController="Opportunity"> <apex:pageBlock > <apex:pageBlockTable value="{!Opportunity.OpportunityLineItems}" var="oli"> <apex:column value="{!oli.Quantity}"/> <apex:column value="{!oli.ListPrice}"/> <apex:column value="{!oli.TotalPrice}"/> <apex:column value="{!oli.Sale_Type__c}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:page>

 

I also want the first column "Action" in there as well, so that I can present the "Edit | Del" hyperlinks, slightly modified for my purposes, but still retaining the Salesforce.com look.

 

How do I put that into the markup above?  I get the feeling that it's not something I can easily put into a pageBlockTable.  If not, where (or how) do I put it in?

 

Also, my next problem is how to get the pageBlockButtons section in so that it refers to the OpportunityLineItems methods (whatever they actually are??? I can't seem to find standard controller methods anywhere in documentation).

 

Thanks! 

Message Edited by RDN_LHR on 04-09-2009 03:57 AM
Best Answer chosen by Admin (Salesforce Developers) 
RDN_LHRRDN_LHR

I wish I could say I worked this out by using the excellent documentation but I didn't.  I did search it high and low.  I do wish the documentation was better arranged and more complete.

 

Anyway, here was my solution eventually.

 

 

<apex:page standardController="Opportunity"> <apex:form > <apex:pageBlock > <apex:pageBlockButtons location="top" > <apex:commandButton action="{!URLFOR($Action.OpportunityLineItem.AddProduct, Id)}" value="Add Product" /> <apex:commandButton action="{!URLFOR($Action.OpportunityLineItem.EditAllProduct, Id)}" value="Edit All" /> <apex:commandButton action="{!URLFOR($Action.OpportunityLineItem.ChoosePriceBook, Id)}" value="Choose Price Book" /> <apex:commandButton action="{!URLFOR($Action.OpportunityLineItem.Sort, Id)}" value="Sort" /> </apex:pageBlockButtons> <apex:pageBlockTable value="{!Opportunity.OpportunityLineItems}" var="oli"> <apex:column headerValue="Action"> <b><apex:outputLink value="{!URLFOR($Action.OpportunityLineItem.Edit, oli.Id)}">Edit</apex:outputLink></b> | <b><apex:outputLink rendered="{!oli.Renewal_Line_Item__c != true}" value="{!URLFOR($Action.OpportunityLineItem.Delete, oli.Id)}">Del</apex:outputLink></b> </apex:column> <apex:column headerValue="Product"> <apex:outputLink value="{!URLFOR( $Action.Product2.View ,oli.PricebookEntry.Product2Id)}">{!oli.PricebookEntry.Name}</apex:outputLink> </apex:column> <apex:column value="{!oli.Quantity}"/> <apex:column value="{!oli.ListPrice}"/> <apex:column value="{!oli.UnitPrice}"/> <apex:column value="{!oli.TotalPrice}"/> <apex:column value="{!oli.Sale_Type__c}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>

 

All Answers

RDN_LHRRDN_LHR

I wish I could say I worked this out by using the excellent documentation but I didn't.  I did search it high and low.  I do wish the documentation was better arranged and more complete.

 

Anyway, here was my solution eventually.

 

 

<apex:page standardController="Opportunity"> <apex:form > <apex:pageBlock > <apex:pageBlockButtons location="top" > <apex:commandButton action="{!URLFOR($Action.OpportunityLineItem.AddProduct, Id)}" value="Add Product" /> <apex:commandButton action="{!URLFOR($Action.OpportunityLineItem.EditAllProduct, Id)}" value="Edit All" /> <apex:commandButton action="{!URLFOR($Action.OpportunityLineItem.ChoosePriceBook, Id)}" value="Choose Price Book" /> <apex:commandButton action="{!URLFOR($Action.OpportunityLineItem.Sort, Id)}" value="Sort" /> </apex:pageBlockButtons> <apex:pageBlockTable value="{!Opportunity.OpportunityLineItems}" var="oli"> <apex:column headerValue="Action"> <b><apex:outputLink value="{!URLFOR($Action.OpportunityLineItem.Edit, oli.Id)}">Edit</apex:outputLink></b> | <b><apex:outputLink rendered="{!oli.Renewal_Line_Item__c != true}" value="{!URLFOR($Action.OpportunityLineItem.Delete, oli.Id)}">Del</apex:outputLink></b> </apex:column> <apex:column headerValue="Product"> <apex:outputLink value="{!URLFOR( $Action.Product2.View ,oli.PricebookEntry.Product2Id)}">{!oli.PricebookEntry.Name}</apex:outputLink> </apex:column> <apex:column value="{!oli.Quantity}"/> <apex:column value="{!oli.ListPrice}"/> <apex:column value="{!oli.UnitPrice}"/> <apex:column value="{!oli.TotalPrice}"/> <apex:column value="{!oli.Sale_Type__c}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>

 

This was selected as the best answer
SteveAnderson41SteveAnderson41
What could be added to the documentation that would have helped you?
hokusaihokusai
Example code for multiple design patterns.  Perhaps an apex exchange package that allows us to see many examples in the front and back end. 
RDN_LHRRDN_LHR

Here's why I said what I said earlier about documentation:

 

Searching "URLFOR" in the Force.com Apex Code Language Reference, Spring '09  returns a "No Topics Found" message.

 

This is just one example of many that I've come across since I started at all this a few months ago. 

hokusaihokusai
In fairness URLFOR is in the Visualforce Documentation and not the Apex Developers guide. But hopefully the Salesforce team sees the need for a massive increase in the example code.
ShikibuShikibu

URLFOR in the VisualForce documentation does not document the arguments for actions. There are no bits of sample code. I've struggled to learn how to use it, from bits of code in the forums that demonstrate use cases not hinted at by the VF guide.

 

It would be great if Salesforce would open up the docs to allow us to post comments. That way we could collectively improve the code, adding what we learn. 

ShikibuShikibu

RDN, thanks for posting this. Doesn't the delete link, though, immediately delete, rather than demanding a confirmation like the action column does?

 

And then unceremoniously dump user into the Opportunity tab, rather than returning to the referring page, as an Action Column would? 

Message Edited by Shikibu on 07-15-2009 03:18 PM