1Workflow::History(3) User Contributed Perl Documentation Workflow::History(3)
2
3
4
6 Workflow::History - Recorded work on a workflow action or workflow
7 itself
8
10 # in your action
11 sub execute {
12 my ( $self, $wf ) = @_;
13 my $current_user = $wf->context->param( 'current_user' );
14 # ... do your work with $ticket
15 $wf->add_history( action => 'create ticket',
16 user => $current_user->full_name,
17 description => "Ticket $ticket->{subject} successfully created" );
18 }
19
20 # in your view (using TT2)
21 [% FOREACH history = workflow.get_history %]
22 On: [% OI.format_date( history.date, '%Y-%m-%d %H:%M' ) %]<br>
23 Action: [% history.action %] (ID: [% history.id %])<br>
24 by: [% history.user %]<br>
25 [% history.description %]
26 [% END %]
27
29 Every workflow can record its history. More appropriately, every action
30 the workflow executes can deposit history entries in the workflow to be
31 saved later. Neither the action nor the workflow knows about how the
32 history is saved, just that the history is available.
33
35 Public Methods
36
37 new( \%params )
38
39 Create a new history object, filling it with properties from
40 "\%params".
41
42 set_new_state( $new_state )
43
44 Assigns the new state $new_state to the history if the state is not
45 already assigned. This is used when you generate a history request in a
46 Workflow::Action since the workflow state will change once the action
47 has successfully completed. So in the action you create a history
48 object without the state:
49
50 $wf->add_history(
51 Workflow::History->new({
52 action => "Cocoa Puffs",
53 description => "They're magically delicious",
54 user => "Count Chocula",
55 })
56 );
57
58 And then after the new state has been set but before the history
59 objects are stored the workflow sets the new state in all unsaved his‐
60 tory objects.
61
62 is_saved()
63
64 Returns true if this history object has been saved, false if not.
65
66 Properties
67
68 · id - ID of history entry
69
70 · workflow_id - ID of workflow to which history is attached
71
72 · action - Brief description of action taken
73
74 · description - Lengthy description of action taken
75
76 · date - Date history noted, set to a DateTime object.
77
78 · user - User name (ID, login, or full name, up to you) taking action
79 (may be blank)
80
81 · state - State of workflow as history was recorded.
82
83 #=head3 clear_saved
84
85 #=head3 set_saved
86
88 Workflow
89
91 Copyright (c) 2003-2004 Chris Winters. All rights reserved.
92
93 This library is free software; you can redistribute it and/or modify it
94 under the same terms as Perl itself.
95
97 Chris Winters <chris@cwinters.com>
98
99
100
101perl v5.8.8 2007-04-25 Workflow::History(3)