Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 2984
0 votes
Accepted

SOQL aggregate functions number fields

You should include the text field in your field list. Also, having is used to find a group of records that meet some criteria (for example, multiple records that have the same name). It looks like you …
sfdcfox's user avatar
  • 502k
3 votes
Accepted

AggregateResult Use Case Best Practice

Use AggregateResult when possible. It always performs at least as well as manual loops. The more rows you need to process, the more you'll save in CPU time.
sfdcfox's user avatar
  • 502k
1 vote

Updating parent record via Batch Apex

There's no direct way to do this without a bit of extra setup, but it is possible. First, you need to create a new Account Lookup field on Campaign Member. Next, you would want to write a trigger or P …
sfdcfox's user avatar
  • 502k
14 votes
Accepted

Aggregate SOQL - How Many Fields Can Be Grouped?

The maximum is 32 groupings. If you exceed this, you receive the following error: System.QueryException: Group By must contain 32 fields or less This used to be in the documentation, but I can't seem …
sfdcfox's user avatar
  • 502k
1 vote
Accepted

Compile error - Return value must be of type : List

Your method declares that it returns List<Funding_Cycles_TA__c>, but you're actually returning a List<Wk_PerformanceQueryResults>. You'll want to change your return type to match.
sfdcfox's user avatar
  • 502k
1 vote
Accepted

Max aggrigate query has huge cost against # query rows returned limit

Based on comments: Filtering, ordering by (even with LIMIT), or grouping by a formula field always results in a full table scan. This will result in 50,000+ row errors or non-selective filter errors …
sfdcfox's user avatar
  • 502k
3 votes

How can you aggregate a checkbox field with SOQL?

You'll need to calculate the average manually. You'll want to group the data like this: SELECT Count(ID), OwnerId, MyCheckbox__c FROM Object__c GROUP BY OwnerID, MyCheckbox__c You could map the ave …
sfdcfox's user avatar
  • 502k
5 votes

What is the coalesce() eqivalent?

No. There's no way to get the results you're looking for. SOQL is a very limited query language that isn't as robust as full SQL, although it handles relationships easier than SQL.
sfdcfox's user avatar
  • 502k
7 votes
Accepted

SOQL SUM() function not calculating the correct value

Any time you use an aggregate function, it is always in the organization's currency. … You can’t convert the result of an aggregate function into the user’s currency by calling the convertCurrency() function. …
sfdcfox's user avatar
  • 502k
2 votes
Accepted

Why is my aggregate query returning no rows when called during test?

You're running into the Isolation of Test Data from Organization Data in Unit Tests. In other words, by default, unit tests can't see live data. This makes your unit tests more reliable, because they' …
sfdcfox's user avatar
  • 502k
5 votes
Accepted

get MIN date with Id from aggregate result query

In this specific case, it'd be a lot easier to order by date ascending and limit by 1: MyObject__c minDOBRecord = [SELECT Id FROM MyObject__c WHERE Id = :setIds ORDER BY DOB__c ASC LIMIT 1]; In rea …
sfdcfox's user avatar
  • 502k
1 vote
Accepted

Null Pointer exception on a Map get()

If zero rows would be returned, there's no entry in the map for the record, so you need to check for that first: private static void updateRiskScoreTotalOnSiteSurvey(List<Site_Survey__c> newSurveys) { …
sfdcfox's user avatar
  • 502k
2 votes
Accepted

Database.Stateful in Batch gives errors

global List<Sales_Data_Aggregated__c> listSalesDataAggregated_Upsert = new List<Sales_Data_Aggregated__c>(); global List<Sales_Data_Aggregated__c> listSalesDataAggregated_Delete = new List<Sales_Data_ …
sfdcfox's user avatar
  • 502k
1 vote

Bulkify Aggregation Trigger

You can do this, but it requires slightly more code, may be much slower than your current code, and may actually run in to different limits (the 2000 aggregate result limit). …
sfdcfox's user avatar
  • 502k
1 vote
Accepted

LWC for:each needs 3 levels, but SOQL query aggregate relationship limited to 2. What's your...

If you wanted to do all the queries from the top level, you could use three queries, return the data to the client, and do further parsing there. public class Response { @AuraEnabled public Containe …
sfdcfox's user avatar
  • 502k

15 30 50 per page