[Rt-commit] rt branch, 5.0-trunk, updated. rt-5.0.1-538-g140e6ba367

? sunnavy sunnavy at bestpractical.com
Tue Jun 22 10:47:00 EDT 2021


The branch, 5.0-trunk has been updated
       via  140e6ba367e11f8aac18d9ed46ec6f0151abac31 (commit)
       via  c6287241cdeac487aa2f7f88793e5e4904846881 (commit)
      from  d321afd294bd87c45f3ace1870732a3a25be9011 (commit)

Summary of changes:
 lib/RT/Action/CreateTickets.pm | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

- Log -----------------------------------------------------------------
commit c6287241cdeac487aa2f7f88793e5e4904846881
Author: craig kaiser <craig at bestpractical.com>
Date:   Wed Jun 2 09:36:40 2021 -0400

    Allow skipping of create ticket blocks through passing arg
    
    This allows for logic to be placed inside of the '===' create ticket
    blocks to decide if a ticket should be created or not.

diff --git a/lib/RT/Action/CreateTickets.pm b/lib/RT/Action/CreateTickets.pm
index af3d9d0779..9127106a59 100644
--- a/lib/RT/Action/CreateTickets.pm
+++ b/lib/RT/Action/CreateTickets.pm
@@ -176,6 +176,26 @@ template section after the block, you must scope it with C<our> rather
 than C<my>. Just as with other RT templates, you can also include
 Perl code in the template sections using C<{}>.
 
+=head3 SkipCreate
+
+This flag allows for ticket creation to be skipped programatically.
+Taking a look at the example above the template creates two different
+tickets, maybe a second approval ticket shouldn't be created if the
+ticket's priority is low. Using Perl logic we can check some information
+about the ticket and decide using this flag if we should skip creating
+this ticket:
+
+ ===Create-Ticket: two
+ SkipCreate: {$Tickets{'TOP'}->PriorityAsString eq 'Low' ? 1 : 0}
+ Subject: Manager approval
+ Type: approval
+ Depended-On-By: TOP
+ Refers-To: {$Tickets{"create-approval"}->Id}
+ Queue: ___Approvals
+ Content-Type: text/plain
+ Content: Your approval is requred for this ticket, too.
+ ENDOFCONTENT
+
 =head2 Acceptable Fields
 
 A complete list of acceptable fields:
@@ -223,6 +243,8 @@ A complete list of acceptable fields:
        CF-name           => custom field value
        CustomField-name  => custom field value
 
+       SkipCreate        => 0/1, if true, skip this create ticket block
+
 Fields marked with an C<*> are required.
 
 Fields marked with a C<+> may have multiple values, simply
@@ -318,8 +340,17 @@ sub CreateByTemplate {
         $T::ID    = $template_id;
         @T::AllID = @{ $self->{'create_tickets'} };
 
+        my (@links_local, @postponed_local);
         ( $T::Tickets{$template_id}, $ticketargs )
-            = $self->ParseLines( $template_id, \@links, \@postponed );
+            = $self->ParseLines( $template_id, \@links_local, \@postponed_local );
+
+
+        if ( $ticketargs->{'SkipCreate'} ) {
+            RT::Logger->debug( "Skip flag found for template $template_id, skipping" );
+            next;
+        }
+        push @links, @links_local;
+        push @postponed, @postponed_local;
 
         # Now we have a %args to work with.
         # Make sure we have at least the minimum set of
@@ -733,6 +764,7 @@ sub ParseLines {
         FinalPriority   => $args{'finalpriority'} || 0,
         SquelchMailTo   => $args{'squelchmailto'},
         Type            => $args{'type'},
+        SkipCreate      => $args{'skipcreate'} || 0,
     );
 
     if ( $args{content} ) {

commit 140e6ba367e11f8aac18d9ed46ec6f0151abac31
Merge: d321afd294 c6287241cd
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Jun 22 22:35:33 2021 +0800

    Merge branch '5.0/create-tickets-skip-flag' into 5.0-trunk


-----------------------------------------------------------------------


More information about the rt-commit mailing list