matt
|
| Posted: 09/07/2005, 10:49 AM |
|
I'm looking for ideas on how to implement application behavior that advances an object (i.e. a row on a db) through a set of pre-defined states. For example, if the object is in state A, it can go to either state B or state C. If in state B, it can go back to A or to D. I thought I'd do this by manipulating the contents of a listbox based on the actual value on the DB, but that doesn't seem to be possible. Presenting all possible values in a listbox and then telling the user afterwards that they've selected an invalid one is probably possible, but not desirable behavior.
Any ideas on other ways to approach the problem?
Thanks.
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 09/07/2005, 1:06 PM |
|
Unfortunately I didn't understand your question. Possibly someone else will understand it, but it may help if you could explain your problem in non-technical terms. Or possibly you could provide an example of any Website that functions the way you described ?
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
Walter Kempees
|
| Posted: 09/07/2005, 2:39 PM |
|
peterr;
his real question is in this topic under : retreiving values from a listbox.
Matt:
Is this correct:
you would like to have a record form on 'a' record from the database,
on the form a listbox 'status' presenting from a range of possible values
only values that
have a predefined meaning according to the present state of the record
retreived.
example :
status possible values are A, B, C, D, E, F
the record retreived has status A, so the user is presented with a dropdown
containing only B and C
the record retreived has status B, so the user is presented with a dropdown
containing only A and D
and so on.
It is used in an ordering/tasking/workflow/shopping application where status
could be
A -awaiting approval
B- evaluating
C- approved
D- denied
If this is the case, confirm and we (forum users) take it from there.
Walter
Hum, could even be done with the directory (breadcrum)
|
|
|
 |
matt
|
| Posted: 09/07/2005, 2:54 PM |
|
Yes, Walter, you've given a much clearer example than I did. That is exactly the type of behavior that I want. Thanks.
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 09/07/2005, 11:57 PM |
|
We use such system with a workflow internally, where each user belongs to a list of roles, and each role allows users to specify only selected statuses, severities, priorities, etc.
You can simply use a proper SQL statement for your listbox (in the Data Source property), therefore I don't think that there are "states" involved here, or there is a need to advance some objects 
For example we use such SQL:
SELECT status_id, status_name FROM statuses WHERE status_id IN (SELECT status_id FROM role_statuses WHERE role_id = {current_role_id} )
Then "current_role_id" is setup as a parameter with some lookup expression that retrieves the current user's role from the database.
You can also populate listboxes programmaticaly as shown in the docs: http://docs.codecharge.com/studio/html/ProgrammingTechn...stOfValues.html
Hope this helps.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
DonB
|
| Posted: 09/08/2005, 7:29 AM |
|
To further expand on this topic, I would suggest a 'state table' be added to
the database. This table would look like this:
Let's call this table StateTransitions
PresentState NextState
A B
A C
B D
C E
In other words, for each possible PresentState of your process, the states
to which it can transition are listed as 'NextState' values. Now you can
write a data source query for the listbox that incorporates one parameter -
the 'PresentState' value. Your data source will contain all the NextState
values for any given PresentState
Let's call this table StateLookups
StateCode StateText
A State A
B State B
C State C
D State D
E State E
Your data source for the listbox would be SQL that looks like this:
SELECT sl.*
FROM StateLookups AS sl
INNER JOIN StateTransitions AS st
ON st.NextState = sl.StateCode
WHERE st.PresentState = {s}
's' would be a parameter whose value is obtained from a datasource column in
the record being edited. Thus, whatever the current value is, you get a
list of the permissible transitions. And, it's table-driven so you have no
extra code to maintain.
That's the basic idea, anyway. There may be some details to iron out, like
what do you do for 'insert' operations where you have no PresentState.
It might be that the PresentState is tracked via a URL parameter, if the
'state' being maintained does not need to be persistent (maintained between
sessions).
--
DonB
http://www.gotodon.com/ccbth
"matt" <matt@forum.codecharge> wrote in message
news:5431f61af0d104@news.codecharge.com...
> Yes, Walter, you've given a much clearer example than I did. That is
exactly the
> type of behavior that I want. Thanks.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
Walter Kempees
|
| Posted: 09/08/2005, 10:29 AM |
|
Right Donb, enough is enough!
He posses a problem, I describe it, You formulate the solution now all we
need is Peterr to build it.
;-P
|
|
|
 |
|