db query with deluge on submit

db query with deluge on submit

Not sure if this is a feature request or what. I'm looking to auto-fill one of my form fields, but only on submit, not sooner, since the fill value will be driven by a db query.

I have 2 forms, 'project' and 'job'. Let's say 'project' has 3 records:

cake
butter
mustard

In my system, job codes consist of their associated project code + a 3-digit number, which is auto-incremented.

cake001 - first job under the 'cake' project
cake002 - second job under the 'cake' project
butter001 - first job under the 'butter' project
...

My 'job' form contains a pulldown populated from the project codes in 'project' (easily done in Creator). However, I need to then append those 3 digits on submit in order to create the new job code, e.g. butter002.

This involves a few tasks on submit:

- query the job table for existing records matching the same project code
- determine the highest integer of those matched records
- increment by one and submit that value back

This comes down to whether I can perform a custom db query via deluge -- e.g. with a DB API module or some other hook.

So before I go any further -- is this, or anything close to it, possible with ZC/Deluge? Sorry for the n00b question, but I have the impression that I might be trying something that is not possible with the app in its current form, and I just want to get a sense of whether I am spinning my wheels before I plow ahead.

Thanks--