+ my @fields = qw( itemlost withdrawn );
+
+ # Only call GetItem if we need to set an "on" date field
+ if ( $item->{itemlost} || $item->{withdrawn} ) {
+ my $pre_mod_item = GetItem( $item->{'itemnumber'} );
+ for my $field (@fields) {
+ if ( defined( $item->{$field} )
+ and not $pre_mod_item->{$field}
+ and $item->{$field} )
+ {
+ $item->{ $field . '_on' } =
+ DateTime::Format::MySQL->format_datetime( dt_from_string() );
+ }
+ }
+ }
+
+ # If the field is defined but empty, we are removing and,
+ # and thus need to clear out the 'on' field as well
+ for my $field (@fields) {
+ if ( defined( $item->{$field} ) && !$item->{$field} ) {
+ $item->{ $field . '_on' } = undef;
+ }
+ }
+
+