0

I have 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".

1)Im querying on "gmod__Opportunity_Forecast__c " object to retrive the related records ,but it displays all the records on gmod__Opportunity_Forecast__c in Visual force page.

list<gmod__Opportunity_Forecast__c>  opflist = [Select
                                                    id,
                                                    Name,
                                                    gmod__Product__c,
                                                    gmod__Quantity__c,
                                                    gmod__Price__c ,
                                                    gmod__Month__c,
                                                    gmod__date__c,
                                                    gmod__Quarter__c,
                                                    gmod__Amount__c ,
                                                    Actual_Price__c,
                                                    gmod__Year__c,
                                                    gmod__Month_Text__c,
                                                    Forecast_Date__c,
                                                    gmod__Opportunity_Forecast__c.gmod__Product__r.Name
                                                    from gmod__Opportunity_Forecast__c ]; 

I shall appreciate your help.

6
  • 1
    There is no where condition on your query so it will return all records.
    – BarCotter
    Commented Feb 4, 2015 at 12:31
  • @BarCotter:I tried using different ways of query ,but still it does not display the related record.[SELECT Id, Name,gmod__product__r.name from gmod__Opportunity_Forecast__c where createddate != null order by name Asc],[SELECT Id, gmod__product__r.name ,createdby.name from gmod__Opportunity_Forecast__c where gmod__product__r.name like '%BX%'].Is that im doing any blunt mistake in the query.Any help is very much appreciated.
    – nikkey
    Commented Feb 5, 2015 at 16:19
  • Which gmod__Opportunity_Forecast__c record do you want to display in the page?
    – BarCotter
    Commented Feb 5, 2015 at 16:23
  • @BarCotter:The product details which got displayed on "Opportunity" object visual force page ,the same product details should get displayed on custom visual force page on "Quote "object in gmod__Opportunity_Forecast__c section.The issue is when i query on gmod__Opportunity_Forecast__c ,it doesnot retrieve the correct related record from the product.Instead it displays all the records of gmod__Opportunity_Forecast__c.
    – nikkey
    Commented Feb 5, 2015 at 16:29
  • That is because you are not doing a where clause on gmod__Opportunity_Forecast__c e.g. select Id from gmod__Opportunity_Forecast__c where Id = :ofId.
    – BarCotter
    Commented Feb 5, 2015 at 16:35

1 Answer 1

0

You should add a WHERE conditon on Query like .. WHERE gmod__Product__c ! = NULL

So that it will return records which has related gmod__Product__c

1
  • :I tried the where condition but still it displays all the records of gmod__Opportunity_Forecast__c in visual force page.If i use WHERE gmod__Product__c ! = NULL order by name limit 1,it displays the unrelated record of the gmod__Opportunity_Forecast__c .
    – nikkey
    Commented Feb 4, 2015 at 16:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .