Since the code allows processing of several types of workflow instructions, here is another useful use case... setting activity cto a certain number of business days from the case create date. For some reason, business hours is available in apex, but not when setting workflow tasks.
So here is what you need to add to the previous post code sample:
- Add a business hours variable to hold your selected business hours record.
- add 'businesstime' when checking for workflow instructions.
- add a method that processes the 'businesstime' workflow instruction.
You still need the code for the trigger as in the previous post: And now, all you have to do to make the workflow work is to set up the workflow instruction in the description of the workflow task. The trigger will fire, then change the task activity due date, and then remove the instruction from the description. here is an example: