function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SteveOrg93SteveOrg93 

Time based Workflow Rules or Apex Trigger

Hi there, I was hoping I would be able to get some guidance on the preferred solution to get this working in salesforce.

 

There is currenty a formula field in our opportunities that look at three fields to caculate whether an opportunity is active: 

 

AND( IsWon = True, Billing_Start_Date__c  <= TODAY(), Contract_End_Date__c  >= TODAY()).

 

The issue is that I plan on rolling up opportunities that are "active" on the account, however salesforce doesn't support filtering the opportunities for rollup using a formula field.

 

Looking at the conditions of when an opportunity is active, it seems either a workflow rule or apex trigger should be used to update the Active flag in the opportunity so that I could use it as a condition to rollup opps on the account.  However, this will need to trigger on a nighty basis and compare the opportunity date fields to today.  

 

Has anyone worked on a similar solution and would know whether the apex trigger should be appropriate for this solution?Or could I get this to work with time dependent workflow rules?  Any help is greaty appreciated.

 

Thanks!

Steve 

sandeep1989sandeep1989

If it has to update on a nightly basis. i would prefer writing a schedule job which takes into account all the opportunities who have a billing start date greater than today and less than end date. then retrieve all the accounts related to those opportunities and do the summing and store it up in the accounts.