[rt-users] "On Due Date Changed" action?
    Lars Kellogg-Stedman 
    lars at oddbit.com
       
    Tue Nov  4 15:52:41 EST 2008
    
    
  
> I'd like to set up a mechanism that ensures that when the due date on
> a ticket is updated, the due date on any tickets that depend on it
> will also changes.
Well, it took a little research, but this seems to work (inspired by
http://wiki.bestpractical.com/view/OpenDependantsOnResolve):
Custom condition:
if ( ( $self->TransactionObj->Field || '' ) eq 'Due' &&
$self->TicketObj->DueObj->Unix > 0) {
  return(1);
}
return undef;
Custom action preparation code:
1;
Custom action cleanup code:
use RT::Date;
my $parents = $self->TicketObj->DependedOnBy;
my $id = $self->TicketObj->id;
my $dueDate = $self->TicketObj->DueObj;
while( my $l = $parents->Next ) {
  next unless( $l->BaseURI->IsLocal );
  next unless( $l->BaseObj->Status =~ /^(?:new|open|stalled)$/ );
  # Only update the parent due date if it's already set.
  next unless defined $l->BaseObj->DueObj->Unix > 0;
  my $parentDueDate = $l->BaseObj->DueObj;
  next unless $parentDueDate->Diff($dueDate) < 0;
  $l->BaseObj->Comment(Content => <<END);
This ticket depends on ticket \#$id which has a new due
date of ${\$dueDate->AsString}.  The due date on this
ticket has been updated accordingly.
END
  $l->BaseObj->SetDue($dueDate->ISO);
}
1;
-- 
Lars Kellogg-Stedman <lars at oddbit.com>
    
    
More information about the rt-users
mailing list