Difference between revisions of "AutoUpdate Parents with TImeWorked"

From Request Tracker Wiki
Jump to navigation Jump to search
(Created page with "right|300px #############################################################################<br /># # Scrip name: AutoUpdate Parents with TImeWorked<br /># Des…")
 
Line 1: Line 1:
[[File:Placeholder|right|300px]]
[[File:Placeholder|right|300px]]
#############################################################################<br />#
#############################################################################<br />#
# Scrip name:  AutoUpdate Parents with TImeWorked<br /># Description: Automatically add "Time Worked" to all vertical and horizontal<br />#              parent tickets<br />#
# Scrip name:  WorkFlow MemberOf on Time<br /># Description: Automatically add "Time Worked" to all vertical and horizontal<br />#              parent tickets<br />#
# Condition:  User Defined<br /># Action:      User Defined<br /># Template:    Global template: Blank<br /># Stage:      TransactionBatch<br /># Written:    12/10/2010 - Kenn Crocker<br />#
# Condition:  User Defined<br /># Action:      User Defined<br /># Template:    Global template: Blank<br /># Stage:      TransactionBatch<br /># Written:    12/10/2010 - Kenn Crocker<br />#
# Modified:    MM/DD/YYYY - Name/comments<br />#
# Modified:    MM/DD/YYYY - Name/comments<br />#

Revision as of 16:30, 10 December 2010


                                                                                                                                                          1. #
  1. Scrip name: WorkFlow MemberOf on Time
    # Description: Automatically add "Time Worked" to all vertical and horizontal
    # parent tickets
    #
  2. Condition: User Defined
    # Action: User Defined
    # Template: Global template: Blank
    # Stage: TransactionBatch
    # Written: 12/10/2010 - Kenn Crocker
    #
  3. Modified: MM/DD/YYYY - Name/comments
    #

                                                                                                                                                          1. #
  4. ----------------------------------------------------------------------------
    # Custom condition:
    #----------------------------------------------------------------------------
    # Set initial values

my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;

  1. Get out if not for "TimeWorked"

return 0 unless ($trans->Type eq 'Set' &&
$trans->Field eq 'TimeWorked');

return 1;

  1. ----------------------------------------------------------------------------
    # Custom action preparation code:
    #----------------------------------------------------------------------------
    # Set initial values

my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;
my $Time = (($trans->NewValue) - ($trans->OldValue));
my $MemberOf = $ticket->MemberOf;

  1. get out if current ticket is not a "MemeberOf" (child of some parent)

return 0 unless $MemberOf;

  1. Loop thru each parent and add the Child's "TimeWorked" to them
    # You can skip a parent ticket if it is not in active state by uncommenting
    # the next statement

while( my $l = $MemberOf->Next )
{
# next unless( $l->TargetObj->Status =~ /^(?:new|open|stalled)$/ );
my $ParentTime = $l->TargetObj->TimeWorked;
my $NewTime = ($ParentTime + $Time);
$l->TargetObj->SetTimeWorked($NewTime);
}

return 1;

  1. ----------------------------------------------------------------------------
    # Custom action cleanup code: None
    #----------------------------------------------------------------------------
    return 1;