Hi, when an event / condtion is met and an action is fired, I'd like to be able to update my database. Basically, I want to do what you are doing with the workflow log but not have to call it on every configuration, and use custom database. For example, I may have a database field called last_action that I'd like to update when my workflow system sends out an email. I figured that I could do it with a custom action, but then I'd have to add that action to every workflow configuration, I was wondering if there is a hook I can call so I could wirte a handler for it.

mymodule_hook_workflow()

if action = 'email' and event = 'myevent'
then wrte event info to custom db

Thoughts?

Comments

fago’s picture

if action = 'email' and event = 'myevent'
then wrte event info to custom db

-> write an action for it and configure it ?

>but then I'd have to add that action to every workflow configuration
ok, then your example was bad.. ;) No, there is no hook for that. Is there a good use case for something like that?

phazer’s picture

Component: API » Wng API

Let me explain what I'm doing and you can decide if there's a good use case.

I'm marketing a 5 month healh experience. When you sign up you get products, services, podcasts, emails, and private messages delivered over time for the 5 month period. I'm using workflow_ng to handle the workflow. Each night my cron job raises events for all my subscribers, the event passes in the $user, and their current day in the cycle. This is programmed and works great. I have conditions set up to work with this. So for example..

If User is on Day 15 of the cycle then send this particular Email. (This all works great).
I may have 90 emails congifured that will go out to every member over their subscription period, plus my marketing dept will have the ability to enter new emails w/o me having to do any coding (YOO HOO). Thanks Workflog_NG!

I want to have a page that will be their " Health Program Page" on my Drupal Site. Let's say that every time I send them an email, I want to put the date, user, and the subject and contents of the email into a dataase so when they pull up their "Program Page" they can see all the emails, Private messages, and Podcasts, that have beeen delivered to them.

I was thinking it would be a lot easier to hook into the event and be able to take action on what was happening to update the database rather than writing a custom_logging_action n and add it to all 90 configurations that send emails. PLus, if my marketing guy wites an email, but does not add the custom_logging_action, then their health profiles won't be in sync wiht what was actually done.

Does this make sense?

Jim

fago’s picture

ok, what you need is probably logging on per mail basis. As you said, it would be nice if it works even if workflow-ng isn't used.

-> try to implement hook_mail_alter and log the message there.

fago’s picture

Status: Active » Fixed
phazer’s picture

hook_mail_alter would solve my immediate need, but it would seem much more flexible if all the events were passed to the hook instead of just the email event, that way you could do something for any action or event.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.