OpenTicketOnAllMemberResolve

From Request Tracker Wiki
Revision as of 15:15, 6 April 2016 by Admin (talk | contribs) (2 revisions imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Another ScripAction from RuslanZakirov:

Description: open tickets which has link on resolved ticket as member if all members resoved
 
 Condition: On Status Change
 Custom Condition:
 
 Template: Global template: Blank
 
 Action: User defined
 Custom action preparation code: return 1;
 Custom action cleanup code:
  return 1 if ($self->TransactionObj->NewValue !~ /^(?:resolved|deleted|rejected)$/);
  # current ticket is memeber of(child of some parents)
  my $MemberOf = $self->TicketObj->MemberOf;
  while( my $l = $MemberOf->Next ) {
    # we can't check non local objects
    next unless( $l->TargetURI->IsLocal );
    # if parent ticket is not in active state then scrip can skip it
    next unless( $l->TargetObj->Status =~ /^(?:new|open|stalled)$/ );
 
    # the parent ticket has members(current ticket is one of them)
    my $ms = $l->TargetObj->Members();
 
    my $flag = 0;
    while( my $m = $ms->Next ) {
      next unless( $m->BaseURI->IsLocal );
      next unless( $m->BaseObj->Status =~ /^(?:new|open|stalled)$/ );
      $flag = 1;
      last;
    }
    # shouldn't open parent if some children is active
    next if( $flag );
 
 # Uncomment this string if you want open ticket
 # and comment next code down to END word
 #  $l->TargetObj->SetStatus('open');
 
 # This code adds comment to the ticket
    my $id = $self->TicketObj->id;
    my $status = $self->TicketObj->Status;
    $l->TargetObj->Comment(Content => <<END);
 
 Last member(\#$id) of this ticket was $status.
 END
 # end of code that adds comment
 
  }
  return 1;
 

705617733494428679213672_test_num_