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
Prakash@SFDCPrakash@SFDC 

Override "Add Products" button on Opportunity to display records with some filter condition

Hi ,

 

I want to display the records with some filter condition  when i click Add Products button on Opportunity . How can i implement this ?

 

 

Thanks 

Prakash

Sonam_SFDCSonam_SFDC

Hi Prakash,

 

When we try to add product to an opportunity - there is a set of filters you can apply to search for Products.

Are you saying that the Product list should be pre filtered whene you open the Add product page?

 

Prakash@SFDCPrakash@SFDC

Yes Sonam , You are right . Is there any way to do that ?

 

Thanks 

Prakash.

kiranmutturukiranmutturu
you can't do any ways on the standard list...but if you can create a custom button on product and give content source as URL. Create a vf page and have your filter logic in the extension....and remove the standard Add product button and build the same in the custom page... For this you can't standardlistcontroller or recordsetvar ..so you need to build this completely as a custom logic....
Sonam_SFDCSonam_SFDC

Hi Prakash,

 

As kiran explained in the post - you will have to create a custom button to implement the product filtering, create a vf page that popups whent he result with the button is clicked and replace this button with the add products button on the opportunity page layout - products related list

RobLofaroRobLofaro
Or a URL hack, as this article suggests:  https://developer.salesforce.com/forums/ForumsMain?id=906F00000008p4XIAQ  
Jason OrbisonJason Orbison
The easiest is URL hacking, here are to links

https://developer.salesforce.com/forums/?id=906F00000008p4XIAQ


https://sfdc-gyaan.rhcloud.com/tag/product/
 
Pradeep Kumar 454Pradeep Kumar 454
For the above requirement, I have made use of URL hacking. But it does not work in Lightning. Do anyone know the work around for this.
Varshit Bhatia 20Varshit Bhatia 20
i just want to display a vf page on click of 'Add Product' button on Opportunity page layout. Please let me know what possible solutions we have ? 
supriya jain 27supriya jain 27
You can create a custom button and define javascript function

 <apex:pageBlock title="Opportunity Product Summary {!If(lockOpportunityProduct,'(Locked)','')}" id="ProductSummaryPageBlock" >
            <!--Add Product redirects to Add Product standard page -->
                <input type="button" class="custom-btn" value="Add Product" onclick="redirectAddProduct();"  href="javascript:void(0)" style="user-select: auto;" />             
            </apex:pageBlockButtons>------

And Define function:

function redirectAddProduct(){
        //Added for filtering Product based on Opportunity Record Type by supriya jain
       
        if (confirm("Warning! Please click cancel and verify all the fields in Opportunity, otherwise you will get validation error whiling adding products!")) {
             window.top.location.href = '/p/opp/SelectSearch?addTo={!$CurrentPage.parameters.Id}&retURL=%2F{!$CurrentPage.parameters.Id}&PricebookEntrycol0={!$Label.Knowles_Product_Division_Field_Id}&PricebookEntryoper0=e&PricebookEntryfval0={!productDivision}&PricebookEntrycol1=PRODUCT2.ACTIVE&PricebookEntryoper1=e&PricebookEntryfval1=true';
        }         
    }