Skip to main content
Tweeted twitter.com/StackSalesforce/status/815667114421944320
edited tags
Source Link
Adrian Larson
  • 151.4k
  • 38
  • 247
  • 431

I am trying to run this query in apex and run into following error.

    AggregateResult[] groupedResults = [select Campaign__r.id cid, Count(opportunity__c) oppcount, FORMAT(SUM(Opportunity__r.Amount)) oppAmt from Campaign_influence__c where opportunity__c!=null AND Campaign__c in :CampaignList group by Campaign__r.id ];

System.QueryException: Invalid field: 'Opportunity__r':

This query does run fine in developer console 'query editor'. Can you please suggest whatIt also works if I replace FORMAT(SUM(Opportunity__r.Amount)) with just SUM(Opportunity__r.amount). What am I doing wrong here?

I am trying to run this query in apex and run into following error.

    AggregateResult[] groupedResults = [select Campaign__r.id cid, Count(opportunity__c) oppcount, FORMAT(SUM(Opportunity__r.Amount)) oppAmt from Campaign_influence__c where opportunity__c!=null AND Campaign__c in :CampaignList group by Campaign__r.id ];

System.QueryException: Invalid field: 'Opportunity__r':

This query does run fine in developer console 'query editor'. Can you please suggest what am I doing wrong here?

I am trying to run this query in apex and run into following error.

    AggregateResult[] groupedResults = [select Campaign__r.id cid, Count(opportunity__c) oppcount, FORMAT(SUM(Opportunity__r.Amount)) oppAmt from Campaign_influence__c where opportunity__c!=null AND Campaign__c in :CampaignList group by Campaign__r.id ];

System.QueryException: Invalid field: 'Opportunity__r':

This query does run fine in developer console 'query editor'. It also works if I replace FORMAT(SUM(Opportunity__r.Amount)) with just SUM(Opportunity__r.amount). What am I doing wrong here?

added 2 characters in body; edited tags
Source Link
Adrian Larson
  • 151.4k
  • 38
  • 247
  • 431

I am trying to run this query in apex and run into following error.

    AggregateResult[] groupedResults = [select Campaign__r.id cid, Count(opportunity__c) oppcount, FORMAT(SUM(Opportunity__r.Amount)) oppAmt from Campaign_influence__c where opportunity__c!=null AND Campaign__c in :CampaignList group by Campaign__r.id ];

System.QueryException: Invalid field: 'Opportunity__r':

System.QueryException: Invalid field: 'Opportunity__r':

This query does run fine in developer console 'query editor'. Can you please suggest what am I doing wrong here?

I am trying to run this query in apex and run into following error.

    AggregateResult[] groupedResults = [select Campaign__r.id cid, Count(opportunity__c) oppcount, FORMAT(SUM(Opportunity__r.Amount)) oppAmt from Campaign_influence__c where opportunity__c!=null AND Campaign__c in :CampaignList group by Campaign__r.id ];

System.QueryException: Invalid field: 'Opportunity__r':

This query does run fine in developer console 'query editor'. Can you please suggest what am I doing wrong here?

I am trying to run this query in apex and run into following error.

    AggregateResult[] groupedResults = [select Campaign__r.id cid, Count(opportunity__c) oppcount, FORMAT(SUM(Opportunity__r.Amount)) oppAmt from Campaign_influence__c where opportunity__c!=null AND Campaign__c in :CampaignList group by Campaign__r.id ];

System.QueryException: Invalid field: 'Opportunity__r':

This query does run fine in developer console 'query editor'. Can you please suggest what am I doing wrong here?

Source Link

System.QueryException in aggregateResults

I am trying to run this query in apex and run into following error.

    AggregateResult[] groupedResults = [select Campaign__r.id cid, Count(opportunity__c) oppcount, FORMAT(SUM(Opportunity__r.Amount)) oppAmt from Campaign_influence__c where opportunity__c!=null AND Campaign__c in :CampaignList group by Campaign__r.id ];

System.QueryException: Invalid field: 'Opportunity__r':

This query does run fine in developer console 'query editor'. Can you please suggest what am I doing wrong here?