Conversation
aliozdemirosf
suggested changes
Sep 2, 2021
Comment on lines
+18
to
+20
| global Iterable<SObject> start(Database.BatchableContext batchable) { | ||
| return overviewResult; | ||
| } |
Contributor
There was a problem hiding this comment.
You should return a query locator here instead of iterable. reason of batch is to chunk great amount of data. Iterable will fail on that scenario
Owner
Author
There was a problem hiding this comment.
I updated the code but I did not understand which query I write instead of overviewResult variable
Comment on lines
+18
to
+45
| primaryContacts = [SELECT ID, AccountId, Email | ||
| FROM Contact | ||
| WHERE Is_Primary_Contact__c = true]; | ||
|
|
||
| // Fill the map object. | ||
| for (Contact primary : primaryContacts) { | ||
| if (!primaryEmails.containsKey(primary.AccountId)){ | ||
| primaryEmails.put(primary.AccountId, primary.Email); | ||
| } | ||
| } | ||
|
|
||
| // Searching for who has a primary contact "Used in the WHERE clause". | ||
| Set<Id> accountIdSet = primaryEmails.keySet(); | ||
|
|
||
| // Time. | ||
| DateTime nowDate = System.now(); | ||
| Date startDate = Date.newinstance(nowDate.year(), nowDate.month(), 1); | ||
|
|
||
| System.debug('Schedule is starting for: ' + string.valueOfGmt(startDate)); | ||
|
|
||
| overviewResult = [SELECT AccountId, Account.Name AccountName, StageName, format(sum(Amount))SumAmount | ||
| FROM Opportunity | ||
| WHERE AccountId in :accountIdSet | ||
| AND (CreatedDate >= :startDate or LastModifiedDate >= :startDate) | ||
| GROUP BY AccountId, Account.Name, StageName | ||
| ORDER BY AccountId]; | ||
|
|
||
| // Execute. |
Contributor
There was a problem hiding this comment.
This should be handled inside batch apex.
Owner
Author
There was a problem hiding this comment.
Is it okey to keep constructor in the batch ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.