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
mba75mba75 

Replace the product selection page

Is it possible to replace the ui/opportunity/SelectSearch with a visualforce page ?
 
any idea ?
 
 
Ron HessRon Hess
i don't think so, you may be able to hide the add product button and add your own custom button to that related list. I haven't tried this.
PerGeertPerGeert
I am having the same requirements: shouldn't you simple be able to override the standard button Add Product under Opportunity Product with an s-control or page? I have not made the coding doing what I want, but overriding the button with a random s-control seems to bring me to whatever thats s-control brings me to?
 
Best regards,
Per
kinlar-jfkinlar-jf

I know it's been a while since this thread was active - but have you ever completed a custom add product page?

michaelforcemichaelforce

Hey guys, I just recently did an Override of the "Edit" and "Add Products" functions for Opportunity Products with my own Visualforce page.  I was planning on either uploading it to the AppExchange or sharing it on my (recently launched) blog: www.michaelforce.org or both.  But if you don't want to wait for me to do that then have a look here:

 

Setup -> Customize -> Opportunities -> Opportunity Products -> Buttons and Links

 

That's where you do the override.  One thing to note is that in order for you to override the "Add Products" button with Visualforce the page has to implement the standard opportunity controller... but when you go to override the "Edit" button the Visualforce page has to implement the standard opportunityLineItem controller.  So if you want them to go to the same place like I did, just use a redirect on the latter page like so:

 

 

<apex:page standardController="opportunityLineItem" extensions="opportunityProductRedirectExtension" action="{!redirect}">
</apex:page>

 

 

with controller...

 

 

public class opportunityProductRedirectExtension {

    Id oppId;

    public opportunityProductRedirectExtension(ApexPages.StandardController controller) {
        oppId = [select Id, OpportunityId from OpportunityLineItem where Id = :controller.getRecord().Id limit 1].OpportunityId;
    }
    
    public pageReference redirect(){
        return new PageReference('/apex/opportunityProductEntry?id=' + oppId);
    }

}

 

 

In this example "opportunityProductEntry" is the name of my Visualforce page which I've used to override the "Add Product" button... which does all the fancy, sexy product entry stuff.  There is actually a way to do this without the need for Apex on the redirect... you can just put the URL with a merge field in the "{!action}" property of the redirect page... give it a whirl.

 

Hope this helps.

kinlar-jfkinlar-jf

I'm in the middle of creating my own fancy add product page. Is there any chance you'd share the code for what you've alrady accomplished (if it doesn't reveal any trade secrets of course...

 

I've got all products listed in a dataTable with an inputText for quantity. The quantity is not actually for the product, it's for the number of times I'm going to have *that* particular product added to the opportunity.

 

So on my "product add" page I'll have

 

QTY    Product

2              A

3              B

0              C

 

On the next page, my line item edit page would have the typical quantity, description and price but would be populated with:

(we use the same product multiple times on an opportunity...

 

A

A

B
B
B

 

Let me know if there's anything you can / are willing to share.

 

Much appreciate your response!

 

J.F.

prettynerdprettynerd

is there a way to override the "Multi-Line Item" page without having to override the page before it which is the "Product Selection" page???.. its too cumbersome to re-create the "Product Selection" page when i only need to add a custom field in the "Multi-Line Item".. i needed to add a custom field that cannot be added through just editing the Multi-Line fields in the page layout..

michaelforcemichaelforce

prettynerd- I think you are looking to override the "edit all" button.

 

everyone... just an FYI, I posted a "recipe" on michaelforce.org that contains a link to a package with all the code I built for overriding the standard product entry page.  Check it out, I hope it is useful for you:

 

http://www.michaelforce.org/recipeView?id=a0G30000006eVxVEAU

prettynerdprettynerd

@michaelforce: overriding the "Edit All" however does not override the Multi-line Item page when adding Products (the 2nd page after the Product Selection).. our customer wants it in that page while Users add the Products and not when Users edit them.. hope this is clear.. ^_^

michaelforcemichaelforce

Ah yes, I understand.  Well, check out my code... maybe it's a good starting point for you.  It would be easy to add columns to the "shopping cart" section of what I built.

ElkeElke

Hi all,

 

the code in Michaels blog is very helpful for solving this problem, thank you!!

Based on this I developed my own "Add Products" page. Now I want to deploy my code from a sandbox to our production org.

Everything works fine, vf page and apex controller are deployed. But the Link "Add Product" is not be overriden with my VF Page after the deploy. I have to do this manually in our product org by clicking Setup -> Customize -> Opportunities -> Opportunity Products -> Buttons and Links.

Does anybody know which component I have to add to my Deploy in order to set the new VF Page to this "Add Product" Button at the Opportunity Page layout?

Thanks!

Elke

michaelforcemichaelforce

I'm pretty sure that "overrides" for standard object buttons cannot be included in IDE deployments (or packages for that matter).  Although I could be wrong.  I recently deployed a custom object and am pretty sure the overrides came along for the ride... but in this case you're working with standard objects so the overrides would have to be done after the deployment.

RodneyRodney

Hi Michael, thanks for posting the code, it provides a great help!

 

We have around 1,200 products and the list is limited to 100, I would like to exted it to at least 500 in one scrreen. Is that possible? How?

 

Thanks, Rodney

RodneyRodney

I got it... (sorry if it was a silly question, but it is my first try at coding in SFC)

 

Changes on Apex Class opportunityProductEntryExtension from line 115:

 qString+= ' order by Product2.Name';
        qString+= ' limit 501';
        
        system.debug('qString:' +qString);        
        AvailableProducts = database.query(qString);
        
        // RR: Changed to 500! We only display up to 100 results... if there are more than we let the user know (see vf page)
        if(AvailableProducts.size()==501){
            AvailableProducts.remove(500);

 

 

Mayank Joshi.ax1562Mayank Joshi.ax1562

Hi ,

 

I found out relevant information here for overridig Standard Product Selection to Custom Visual Force Page  :

http://crawlapexnvisualforce.blogspot.in/2012/09/salesforce-opportunity-product-extension.html  

 

This might help someone .

michaelforcemichaelforce

^ that awkward moment when someone copies your code and posts it on their blog without giving you credit... ^

Mayank_JoshiMayank_Joshi

Like this .. michaelforce :)

Scott FletcherScott Fletcher
We have happily used michaelforce (https://developer.salesforce.com/forums/ForumsProfile?communityId=09aF00000004HMGIA2&userId=005F0000003FWXKIA4)'s code and added significant adaptations to filter the product list based on user profiles. We have now enabled revenue scheduling on a subset of products, and set up default schedules for them. We now need to update the class and page in order to create default schedules (OpportunityLineItemSchedule) when users add products which are schedule-enabled. We'll update the page to allow users to enter Product Date (OpportunityLineItem.ServiceDate) and the class to upsert OpportunityLineItemSchedule as well as OpportunityLineItem. Has anybody on this thread adapted the code to handle default revenue schedules?
Mitesh SuraMitesh Sura
+ 1 for Michael's solution, numerous companis have used it. I am in same boat (3 years now) as Scott.

@Scott Fletcher, did you update the code to support "defult scheduling" ?? Also, is there way to force defult scheduling without having to write additional trigger/code? I would like to use Salesforce standard logic and would not prefer writing the logic which Salesforce is already doing it.
One way I think it may work is by having "OpportunityLineItem" as standard contorller and then have extension class to overwrite the save method.

Any guidance is much appreciated. Thank you so much for your time.

Mitesh
Varshit Bhatia 20Varshit Bhatia 20
michaelforce 's answer - no 5 from top is the best answer according to me... Thank you so much miechaelforce, you have saved a lot of my time.
Carl FrechetteCarl Frechette

I have been looking everywhere for michaelforce's package or code but it seems to have vanished from the internet. His blog links don't work and even the one who copied his code is  now offline.

Is there anyone who still have the code ?