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