Hot answers tagged

5

You've inadvertently written a fairly rare construct called an instance initialization block: { if(marks >= 35 && marks <= 50) result = 'passed'; else if (marks >= 51 && marks <= 70) result = 'B'; else if (marks >= 71) result ='A'; else result = 'failed'; { system....


3

There is no way to load more than a total of 50K records in a given synchronous session/transaction (as per the documentation), and certainly no way to do this in a trigger. The only way to deal with this sort of thing is to use async processing such as in a Batchable as you mentioned. It is possible to execute certain types of aggregate query across more ...


3

You have to query back the opportunity in order to see the value of the field. Since the value you are showing on the debug shows the value contained in the variable testOpportunity and not the value of the opportunity stored in memory(which was modified by the trigger). add a line after the update to update the value of the variable with the value stored ...


3

When making your JSON, pass in "true" as the second parameter to omit null values. AccWrp a = new AccWrp(); // ... String body = JSON.serialize(a, true); // ...


3

break and continue work on the innermost loop. Your logic is complicated, and can be greatly reduced by prewarming the map. Also, you should check to see if the item should be created before modifying the tempUserAssignment object. All of the optimizations so far end up looking like this: Map<String,tempUserAssignment> mapByManualAmount = new map &...


2

Bulkification is usually about making the number of query calls or update calls unrelated to the number of records involved (e.g. removing a query from inside a loop). If your calculateOcc method is only called once, then there is no need to bulkify. You are probably getting no records because of this: ... where Occurrence__c =: 'myOcc' Instead, you ...


1

The issue here is that your update statement is updating the list of timesheet records, whereas you need it to update a list of contacts. I would rewrite your code as follows: public class batchClass implements Database.Batchable<sObject>{ public Database.QueryLocator start(Database.BatchableContext bc) { String query = 'SELECT Id, ...


Only top voted, non community-wiki answers of a minimum length are eligible