The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.


Workflow::History - Recorded work on a workflow action or workflow itself


This documentation describes version 1.62 of this package


 # in your action
 sub execute {
     my ( $self, $wf ) = @_;
     my $current_user = $wf->context->param( 'current_user' );
     # ... do your work with $ticket
     $wf->add_history( action => 'create ticket',
                       user   => $current_user->full_name,
                       description => "Ticket $ticket->{subject} successfully created" );

 # in your view (using TT2)
 [% FOREACH history = workflow.get_history %]
    On:     [% OI.format_date(, '%Y-%m-%d %H:%M' ) %]<br>
    Action: [% history.action %] (ID: [% %])<br>
    by:     [% history.user %]<br>
    [% history.description %]
 [% END %]


Every workflow can record its history. More appropriately, every action the workflow executes can deposit history entries in the workflow to be saved later. Neither the action nor the workflow knows about how the history is saved, just that the history is available.


Public Methods

new( \%params )

Create a new history object, filling it with properties from \%params.

set_new_state( $new_state )

Assigns the new state $new_state to the history if the state is not already assigned. This is used when you generate a history request in a Workflow::Action since the workflow state will change once the action has successfully completed. So in the action you create a history object without the state:

          action      => "Cocoa Puffs",
          description => "They're magically delicious",
          user        => "Count Chocula",

And then after the new state has been set but before the history objects are stored the workflow sets the new state in all unsaved history objects.


Returns true (1) if this history object has been saved, false (0) if not.


  • id - ID of history entry

  • workflow_id - ID of workflow to which history is attached

  • action - Brief description of action taken

  • description - Lengthy description of action taken

  • date - Date history noted, set to a DateTime object.

  • time_zone - Time zone to pass to the DateTime object.

  • user - User name (ID, login, or full name, up to you) taking action (may be blank)

  • state - State of workflow as history was recorded.


Sets saved state to false and returns 0


Sets saved state to true and returns 1



Copyright (c) 2003-2023 Chris Winters. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Please see the LICENSE


Please see Workflow