[SalesForce] Apex trigger to update field and activate workflow

I am new to Salesforce and recently learned I cannot schedule workflows to run on certain dates, but must manually (or programatically) edit the record to activate the workflow. After some research it looks like an Apex trigger would work better to accomplish this through scheduled Apex. I am not a programmer, and don't know how to accomplish this. Here is what I have so far….which isn't working…

trigger WorkflowTrigger on Policy_c (after update) {
for (Policy
_c obj: trigger.new) {
WF_Apex_Trigger_Date__c = TODAY;
}
}

WF_Apex_Trigger_Date__c is a field on the Policy object that I want to update with the current date. The workflow is written to evaluate any time the record is edited, and attach a time-based task at 120, 60, and 30 days.

Can anyone point me in the right direction, or tell me what I'm doing wrong? Thanks…

Best Answer

You wouldn't be able to use trigger for this either. Just like workflows, triggers only fire when a record is inserted, edited, or deleted. If you have a job that you want to run on a scheduled basis that goes through records and updates them, then you should use scheduled apex.

Related Topic