• BU Home | 
  • News | 
  • Events | 
  •  | 
  •  

Web Services Wiki

Welcome Guest: Login

Advanced Database Example: Submit / Approve / Search

Until I have time to flesh this out, this is just an email written to a colleague who wanted an example on how to do submissions (edit data) and approve (by managers):

> basically I want users to be able to retrieve the data from the
> database, edit it and then submit it to temporary storage for manager
> viewing &
> approval prior to overriding the original data in the database.

This is a bit complicated, let me see if I can explain how I might achieve 
this.  Currently this isn't possible in TroposV2, because I don't have an 
ExternalAction.  TV1 did, and we've implemented an application similar to 
what you describe.  (externalaction would allow setting the form 'action' to 
be something other than tropos).

So, given that I have an external action:

1) Users form:  data is preloaded, user makes changes, submits (via 
externalaction) to some script (pythonscript, fs product, whatever) which 
takes the data and processes it however you want.  This could be to save into 
a 'pending' table, or if you're saving change history you can use one table 
for this entire process.  If you have a change_indicator field, null could 
indicate the approved version, and a timestamp records when the change was 
made (no longer current).  You can add another field ('approved') to indicate 
whether the row is approved.  So: change_ind=NULL and approved=Y means 
'published' row; change_ind=NULL and approved=N means user-submitted, not 
'published' row.

Note: in the tropos form, you may want to have a hidden field containing the 
row_id (i.e. id), so you can match the data.

2) manager viewing & approval:
You can have an external source which displays all 'unpublished' rows, and 
link to a tropos form allowing the manager to edit and approve them.  This 
form would be similar to the users form, except it would have another field 
specifying whether the data can be approved/published.

The workflow is a bit complicated, but whether you use a table with change 
history or two tables, it's pretty much the same.