I don't know enough to be able to reply. Here is code that works. Please
let me know if there's better way. messageID captures the record ID so it
can populate children further down the process
db.InternalMessage.created_by.default = auth.user_id
db.InternalMessage.subjectLine.label=''
db.InternalMessage.messageBody.label=''
## db.InternalMessage.messageThreadID.default = db.InternalMessage.id
# didn't work
form=SQLFORM.factory(db.InternalMessage, labels=None)
if form.process().accepted:
recipientCount = db(db.TempInternalMessageRecipient.thisSessionID
== response.session_id).count()
if recipientCount == 0:
session.flash='You did not select message recipients'
redirect(URL('forgot_to_add_message_recipient'))
messageID =
db.InternalMessage.insert(**db.InternalMessage._filter_fields(form.vars))
form.vars.messageID=messageID
selectedIndividuals =
db((db.TempInternalMessageRecipient.thisSessionID == response.session_id) &
(db.auth_user.id ==
db.TempInternalMessageRecipient.recipientOfMessage)).select()
for row in selectedIndividuals:
db.InternalMessageRecipient.insert(recipientOfMessage=row.auth_user.id,
messageID=messageID)
session.flash='Your message has been sent.'
db(db.InternalMessage.id == messageID.id).update(messageThreadID =
messageID.id)
db(db.TempInternalMessageRecipient.thisSessionID ==
response.session_id).delete()
redirect(URL('information_center'))
return locals()
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.