Good day everyone,

Suppose I have an object "SAMPLE_OBJECT__c" which has a lookup field to "Accounts" object and it also has a another field which is "Value__c". Now what I want to accomplished is that I want to create a field in "Accounts" which is the total of my SAMPLE_OBJECT__c.Value__c from the last month. Is it possible ? If yes what are the possible thing I can do to make it possible. Please help I really need this functionality.


  • With a lookup you will have to use a trigger/ or batch to populate the data – Eric Aug 11 '15 at 5:04
  • Do you want data for each month to be stored or just last month is fine? – Amit Bangad Aug 11 '15 at 6:00
  • @AmitBangad last month is fine. – Hope Aug 11 '15 at 6:28

As I understand, you want to aggregate on Value field of Sample_object__c (last month date) and store aggregate value at account level. You can achieve it by creating an Apex scheduler/ batch, wherein you can query all records of "Sample_object__c" which are of last month and are related to same account and store aggregate value at Account level.

Refer this article to know more about Apex Schedulers:- https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm

  • How can I call this scheduler ? I've tried to create one and then and i've tried to call but nothing happens ? – Hope Aug 11 '15 at 8:42
  • You can schedule a scheduler class from Salesforce ui (Setup> Build> Develop> Apex Classes) and click on "Schedule apex". Also, you can schedule schdedulable class from apex by invoking "System.schedule" method. Refer:- sfdccloudcomputing.blogspot.com/2014/01/… – Anshul Aug 14 '15 at 6:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.