1

I have a managed package installed in my org. It has a custom object as "gmod__Opportunity_Forecast__c ". It has a look up relation with "product" object and api name is give as "gmod__Product__c" and master-detail relationship with "Opportunity" object and api name is give as "gmod__Opportunity__c". It has a Visualforce page created on "Opportunity Object". So whenever record is created on opportunity object with product details, the product details gets appeared in the Visualforce page.

  1. I have created a Custom Visual force page on "Quote"Object with the related objects such as Quoteline item, competitor etc.

  2. Now the requirement is in custom visual force page, I would like to get the "gmod__Opportunity_Forecast__c" details displayed. So written a wrapper class.

  3. The issue is when i query on gmod__Opportunity_Forecast__c, it doesn't retrieve the correct related record from the product.Instead it displays all the records of gmod__Opportunity_Forecast__c.

  4. The product details which got displayed on "Opportunity" object visualforce page, the same product details should get displayed on custom visual force page on "Quote "object in gmod__Opportunity_Forecast__c section.

Any Suggestion PLZ.

Query Used is different ways but still displays all the gmod__Opportunity_Forecast__c records instead of related record.

First Query Used :retrives all the 40 records of gmod__Opportunity_Forecast__c

SELECT Id, gmod__Opportunity_Forecast__c.name,gmod__product__r.Name from gmod__Opportunity_Forecast__c where gmod__product__c!=null
2

It is very hard to understand you scenario but in the stated query:

SELECT Id, gmod__Opportunity_Forecast__c.name, gmod__product__r.Name 
FROM gmod__Opportunity_Forecast__c 
WHERE gmod__product__c!=null

you are not filtering anything else than gmod__product__c!=null which as a matter of fact will result into every record where you have set the lookup-relation to something except empty.

To filter on a specific opportunity or quote, I would expect that you utilize the second relation gmod__Opportunity__c somehow in the WHERE clause of your query, e.g.

SELECT Id, gmod__Opportunity_Forecast__c.name, gmod__product__r.Name 
FROM gmod__Opportunity_Forecast__c 
WHERE gmod__product__c!=null AND gmod__Opportunity__c = :YourCurrentOppId

You need to set the variable YourCurrentOppId to the current displayed recordId.

From the Quote perspective, you can also filter by the same relationship. You just need to use the Standard Field Quote.Opportunity which contains the OppId you need.

But I'm still not sure if I understood everything right from your question...

  • @Ume Heim:The main Scenario is :What ever the product detail is reflected in the "Opportunity"record.The same product details should get reflected in the custom visual force page"in gmod__Opportunity_Forecast__c" section for related record. – nikkey Feb 6 '15 at 11:45
  • as far as I understand you, I stick with my answer: filter you query in the WHERE clause. Can you work on based on that suggestion? If not, please say why? – Uwe Heim Feb 6 '15 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.