[Rt-commit] rtir branch, 5.0/set-sla-by-priority, created. 4.0.1rc1-121-gb46a35b3

Craig Kaiser craig at bestpractical.com
Thu May 21 14:30:29 EDT 2020


The branch, 5.0/set-sla-by-priority has been created
        at  b46a35b32033b2c9d679fed0a6bfb2d7ee74a4e2 (commit)

- Log -----------------------------------------------------------------
commit 252ca887a53a95183e2911952171c2f5cabcea5e
Author: craig kaiser <craig at bestpractical.com>
Date:   Thu May 21 13:16:49 2020 -0400

    Create custom field 'Severity'

diff --git a/etc/initialdata b/etc/initialdata
index 9eb62c56..744985b8 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -157,6 +157,18 @@ die "Please add RT::IR to your Plugins configuration before initializing the dat
         Values      => [],
         Description => 'Customer for Investigations RTIR queue',
     },
+    {   Name        => 'Severity',
+        Type        => 'SelectSingle',
+        RenderType  => 'Dropdown',
+        Queue       => [ 'Incidents', 'Incident Reports', 'Investigations', 'Countermeasures' ],
+        Disabled    => 0,
+        Description => '',
+        Values      => [
+            { Name => "High", SortOrder   => 3 },
+            { Name => "Normal", SortOrder => 2 },
+            { Name => "Low", SortOrder    => 1 },
+        ]
+    },
 );
 
 @ScripActions = (

commit b46a35b32033b2c9d679fed0a6bfb2d7ee74a4e2
Author: craig kaiser <craig at bestpractical.com>
Date:   Thu May 21 14:12:48 2020 -0400

    Set SLA based on priority on priority change

diff --git a/etc/RTIR_Config.pm b/etc/RTIR_Config.pm
index b0534476..4ddfc616 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -740,4 +740,21 @@ Read F<docs/AdministrationTutorial.pod>.
 
 =cut
 
+=head1 RTIR_PriorityToSLA
+
+Set mapping between priority values and SLA's so that when priority is
+updated the corresponding SLA will be set. This feature will only be enabled
+when a priority value matches to an SLA value.
+
+Using priority as string is fine so long as the numeric value of the string matches
+the config value for C<%RTIR_PriorityToSLA>.
+
+Set(%RTIR_PriorityToSLA,
+    0      => 'normal',
+    50     => 'high',
+    100    => 'urgent'
+);
+
+=cut
+
 1;
diff --git a/etc/initialdata b/etc/initialdata
index 744985b8..82ebc79b 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -220,6 +220,10 @@ die "Please add RT::IR to your Plugins configuration before initializing the dat
         Description =>
             'Move all tickets related to an incident to a new constituency',
         ExecModule => 'RTIR_ChangeChildConstituencies'
+    },
+    {   Name => 'RTIR Set SLA Based On Priority',
+        Description => '',
+        ExecModule => 'RTIR_SetSLA'
     }
 );
 
@@ -270,6 +274,11 @@ die "Please add RT::IR to your Plugins configuration before initializing the dat
         ApplicableTransTypes => 'Correspond',
         ExecModule           => 'RTIR_RequireReportActivation',
     },
+    {   Name                 => 'RTIR On Priority Change',           # loc
+        Description          => "Whenever priority changes", # loc
+        ApplicableTransTypes => 'Any',
+        ExecModule           => 'RTIR_PriorityChange',
+    },
 );
 
 @Scrips = (
@@ -382,6 +391,14 @@ die "Please add RT::IR to your Plugins configuration before initializing the dat
         ScripAction    => 'RTIR merge IPs',
         Template       => 'Blank'
     },
+    {
+        Description => "On Priority Change Set SLA",
+        Queue =>
+            [ 'Incidents', 'Incident Reports', 'Investigations', 'Countermeasures' ],
+        ScripCondition => 'RTIR On Priority Change',
+        ScripAction    => 'RTIR Set SLA Based On Priority',
+        Template       => 'Blank'
+    },
 
 );
 
diff --git a/lib/RT/Action/RTIR_SetSLA.pm b/lib/RT/Action/RTIR_SetSLA.pm
new file mode 100644
index 00000000..dbae3e61
--- /dev/null
+++ b/lib/RT/Action/RTIR_SetSLA.pm
@@ -0,0 +1,35 @@
+use strict;
+use warnings;
+
+package RT::Action::RTIR_SetSLA;
+
+use base qw(RT::Action::SLA);
+
+=head2 Prepare
+
+=cut
+
+sub Prepare {
+    return 1;
+}
+
+=head2 Commit
+
+Set SLA based on Priority.
+
+=cut
+
+sub Commit {
+    my $self = shift;
+
+    my $priority_to_sla = RT::Config->Get( 'RTIR_PriorityToSLA' ) || ();
+
+    if ( $priority_to_sla->{ $self->TicketObj->Priority } ) {
+        my ($ret, $msg) = $self->TicketObj->SetSLA( $priority_to_sla->{ $self->TicketObj->Priority } );
+        RT::Logger->error( "Could not set ticket SLA from priority: $msg" ) unless $ret;
+        return $ret;
+    }
+    return 1;
+}
+
+1;
diff --git a/lib/RT/Condition/RTIR_PriorityChange.pm b/lib/RT/Condition/RTIR_PriorityChange.pm
new file mode 100644
index 00000000..840c38cf
--- /dev/null
+++ b/lib/RT/Condition/RTIR_PriorityChange.pm
@@ -0,0 +1,29 @@
+package RT::Condition::RTIR_PriorityChange;
+
+use base 'RT::Condition';
+
+use strict;
+use warnings;
+
+=head1 RTIR_PriorityChange
+
+Returns true when priority value is updated.
+
+=cut
+
+sub IsApplicable {
+    my $self = shift;
+
+    if ( $self->TransactionObj->Type eq 'Create' ) {
+        return unless $self->TicketObj->Priority;
+        return 1;
+    }
+    else {
+        return unless $self->TransactionObj->Field eq 'Priority';
+        return unless $self->TransactionObj->NewValue;
+        return 1;
+    }
+    return;
+}
+
+1;
diff --git a/lib/RT/Condition/RTIR_PrioritySeverityChange.pm b/lib/RT/Condition/RTIR_PrioritySeverityChange.pm
new file mode 100644
index 00000000..e69de29b

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


More information about the rt-commit mailing list