AutoUpdate Parents with TImeWorked: Difference between revisions
Jump to navigation
Jump to search
(Created page with "right|300px #############################################################################<br /># # Scrip name: AutoUpdate Parents with TImeWorked<br /># Des…") |
m (5 revisions imported) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<pre> | |||
############################################################################# | ############################################################################# | ||
# Scrip name: | # | ||
# Condition: | # Scrip name: WorkFlow MemberOf on Time | ||
# Modified: | # Description: Automatically add "Time Worked" to all vertical and horizontal | ||
############################################################################# | # parent tickets | ||
#---------------------------------------------------------------------------- | # | ||
# Condition: User Defined | |||
# Action: User Defined | |||
# Template: Global template: Blank | |||
# Stage: TransactionBatch | |||
# Written: 12/10/2010 - Kenn Crocker | |||
# | |||
# Modified: MM/DD/YYYY - Name/comments | |||
# | |||
############################################################################# | |||
# | |||
#---------------------------------------------------------------------------- | |||
# Custom condition: | |||
#---------------------------------------------------------------------------- | |||
# Set initial values | |||
my $trans = $self->TransactionObj; | my $trans = $self->TransactionObj; | ||
my $ticket = $self->TicketObj; | |||
# Get out if not for "TimeWorked" | # Get out if not for "TimeWorked" | ||
return 0 unless ($trans->Type eq 'Set' && | return 0 unless ($trans->Type eq 'Set' && $trans->Field eq 'TimeWorked'); | ||
return 1; | return 1; | ||
#---------------------------------------------------------------------------- | #---------------------------------------------------------------------------- | ||
# Custom action preparation code: | |||
#---------------------------------------------------------------------------- | |||
# Set initial values | |||
my $trans = $self->TransactionObj; | my $trans = $self->TransactionObj; | ||
my $ticket = $self->TicketObj; | |||
my $Time = (($trans->NewValue) - ($trans->OldValue)); | |||
my $MemberOf = $ticket->MemberOf; | |||
# get out if current ticket is not a "MemeberOf" (child of some parent) | # get out if current ticket is not a "MemeberOf" (child of some parent) | ||
Line 23: | Line 44: | ||
return 0 unless $MemberOf; | return 0 unless $MemberOf; | ||
# Loop thru each parent and add the Child's "TimeWorked" to them | # 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 ) | 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; | return 1; | ||
#---------------------------------------------------------------------------- | #---------------------------------------------------------------------------- | ||
# Custom action cleanup code: None | |||
#---------------------------------------------------------------------------- | |||
return 1; | |||
</pre> |
Latest revision as of 15:03, 6 April 2016
############################################################################# # # Scrip name: WorkFlow MemberOf on Time # Description: Automatically add "Time Worked" to all vertical and horizontal # parent tickets # # Condition: User Defined # Action: User Defined # Template: Global template: Blank # Stage: TransactionBatch # Written: 12/10/2010 - Kenn Crocker # # Modified: MM/DD/YYYY - Name/comments # ############################################################################# # #---------------------------------------------------------------------------- # Custom condition: #---------------------------------------------------------------------------- # Set initial values my $trans = $self->TransactionObj; my $ticket = $self->TicketObj; # Get out if not for "TimeWorked" return 0 unless ($trans->Type eq 'Set' && $trans->Field eq 'TimeWorked'); return 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; # get out if current ticket is not a "MemeberOf" (child of some parent) return 0 unless $MemberOf; # 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; #---------------------------------------------------------------------------- # Custom action cleanup code: None #---------------------------------------------------------------------------- return 1;