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
WycadoWycado 

Apex Trigger for Workflow

I am not a developer; hence my posting this here. I have a workflow that I want to fire when a formula field evaluates to a certain value. The problem is, standard workflow will only trigger on record edits, and I'm not updating the record. 

 

Surely there is an Apex Trigger 'recipe' out there that I could use for this? Any guidance appreciated. 

Vinit_KumarVinit_Kumar

Trigger would also be invoked on DML event,like (insert,update,etc).I mean you need to insert or update the record to invoke the Trigger.

 

Please be clear about your requirement,then we can help you out.

MartinHaagenMartinHaagen

Hi Wycado,

 

what is the reason you can trigger the workflow from a formula field value? How is the  formula field constructed?

 

 

WycadoWycado

That's my problem- I can't trigger off a field update.

 

I have a custom formula text field that gets the value "XXX" when the date equals the date on another field. But while the custom formula field gets the right value, that does not cause an 'edit' of the record, so the workflow cannot be triggered on this. Workflows want to see a record either created or edited. 

 

I don't know Apex Triggers, but I thought there must be some way to cause what I want - an email to be sent when the formula text field goes to "XXX". 

MartinHaagenMartinHaagen

Hi Wycado,

 

there is a way to solve this via APEX. You should have a look at the schedulable / batchable api:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm

 

There are example code on the page I reference. However this is pretty advanced and if you are not a experienced Salesforce developer it might be a real challenge. However it is not unmanagable. 

 

However before I would have gone down this route I would make sure the bussiness objective couldn't be solved by other means (timed workflows - I don't know these well enough to say if that would work, scheduled reports etc). 

 

Let me know if this brings you closer to your goal!