+ Start a Discussion
Alex MerwinAlex Merwin 

Custom Link to Report w/ Opportunity Products, from Opportunity Detail Pages

When users have added Products to an Opportunity, we frequently have a need to reference information about the Products out of SalesForce. Therefore, we want to have an Export functionality from the Opportunity Page, exporting details about the Products associated with that Opportunity. 

I've tried a few routes for this, but haven't found a solution yet. Custom Links to Reports, with a Product ID passed in the query string of the URL as PV0 works well, but only for a single product (so, I've got that 'export' button added to the Product Detail page, but then users would have to pull reports one by one, waste of time as we sometimes have 25+ products associated with one opportunity). 

Is there some APEX I could use to populate a custom field on the Opportunity object (Export_All_Inventory_Pkg_Reference__c) with all of the Product_ID__c values associated with that opportunity (note this is a Custom system generated ID field, on the Opportunity Product object)? Each Product_ID__c would need to be comma delimited. 

If so, I could add a Custom Link button to the Opportunity detail page for 'Export Products', and populate it with this Export_All_Inventory_Pkg_Reference__c value, and I think it would work. 

FYI, been trying to figure this out on another thread too, but a different method.  (https://developer.salesforce.com/forums/ForumsMain?id=906F0000000MGQcIAO)
Pankaj GangpariaPankaj Gangparia
You can pass Opportunity id instead of product id in url and in controller fetch all product related to opportunity.