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
Matt TindallMatt Tindall 

Trigger Workflow Rule daily?

Hello,

 

First time writing here so my apologies if I’m not as in depth / clear about my issue.

 

I’ve hit a brick wall with my formulas with my desired solution hitting its character limit. My work around was to involve a workflow rule that would complete a field update to determine if the "Commission cut-off date" exceeded the date of "Product added date"

 

I have the workflow rule created but i need it to evaluate the rule and run on a daily basis. Is it possible for me to use APEX or anything like that to automate a trigger for the workflow to run?

Any help would be greatly appreciated!!


Matt Tindall

Best Answer chosen by Admin (Salesforce Developers) 
Peter_sfdcPeter_sfdc
That really depends on your coding ability. Are you a developer/programmer? If not, it will be a big task, and I would recommend seeking help from someone who is familiar with Apex programming.

If you are a programmer, start to dig through Apex resources in developer.force.com. This page is a good one: http://wiki.developerforce.com/page/Apex_Code_Best_Practices

Once you get your head around the basics, you'll need to find out about using Batchable and Schedulable interfaces. These are the two models for creating Apex code that can be invoked by the scheduler.

All Answers

vlachavlacha
Peter_sfdcPeter_sfdc

Your topic subject suggests you want to use Apex to make the triggering of your workflow rule happen on a daily basis. If that's what you are going to do, I would suggest dumping the workflow rule altogether and just performing the field update in Apex entirely.

 

As a one-off, I don't see a problem using Apex to go through and trigger a set of workflow rules that will update values based on a changed workflow rule field update. 

 

But to schedule this? I think you are introducing more potential for error. I'd suggest just writing a scheduled job that will perform this work for you, set it to run as batch if you need to do hundreds of thousands of records, and go with it. 

 

Are you sure there is no way to optimize your formula in some way that will get you what you want? Have you sought help for that in the Formulas and Validation rules section? 

Matt TindallMatt Tindall

Thanks for your reply @Peter_sfdc

If it is possible to do the field update in APEX then that is fine.

I have reviewed our formulas over and over and just cannot shorten them no more. One of the reasons why it is so large is that we have a formula that automatically updated to show the final Friday of the current month and this is why the character count becomes so large.

Are there any guides of writing a scheduled job as this is my first time!

Matt

Peter_sfdcPeter_sfdc
That really depends on your coding ability. Are you a developer/programmer? If not, it will be a big task, and I would recommend seeking help from someone who is familiar with Apex programming.

If you are a programmer, start to dig through Apex resources in developer.force.com. This page is a good one: http://wiki.developerforce.com/page/Apex_Code_Best_Practices

Once you get your head around the basics, you'll need to find out about using Batchable and Schedulable interfaces. These are the two models for creating Apex code that can be invoked by the scheduler.
This was selected as the best answer
Matt TindallMatt Tindall

Thanks for your help @, I'mm reading through all the material now.

Hopefully i will be able piece this together,

All i want to convert to apex is: "IF(Service Date  < Cut_Off__C = "YES", "NO")"

Matt

Rizwan1Rizwan1

hi matt,

 

you can write a batch class where you can fire a query with the filters as stated by you "exceeded the date of "Product added date" and pass the query to query locator also in spring13 salesforce release you can directly schedule the batch class on daily basis. Now there is no need of writing scheduler class for the same .

 

Hope this help.

 

Thanks 

 

Rizwan