[Rt-commit] rtir branch, 5.0/set-sla-by-priority, created. 4.0.1rc1-157-g21ce96d8
Craig Kaiser
craig at bestpractical.com
Wed Jun 3 16:40:49 EDT 2020
The branch, 5.0/set-sla-by-priority has been created
at 21ce96d8754134fec5d7798ae34786cbf77a2376 (commit)
- Log -----------------------------------------------------------------
commit 21ce96d8754134fec5d7798ae34786cbf77a2376
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 bb507a89..9285c614 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -786,4 +786,18 @@ 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.
+
+ Set(%RTIR_PriorityToSLA,
+ Low => 'normal',
+ Medium => 'high',
+ 100 => 'urgent'
+ );
+
+=cut
+
1;
diff --git a/etc/initialdata b/etc/initialdata
index 9eb62c56..34b31017 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -208,6 +208,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_SetSLAFromPriority'
}
);
@@ -258,6 +262,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_CreateOrPriorityChange',
+ },
);
@Scrips = (
@@ -370,6 +379,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_SetSLAFromPriority.pm b/lib/RT/Action/RTIR_SetSLAFromPriority.pm
new file mode 100644
index 00000000..53333c08
--- /dev/null
+++ b/lib/RT/Action/RTIR_SetSLAFromPriority.pm
@@ -0,0 +1,88 @@
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
+# <sales at bestpractical.com>
+#
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
+#
+# This work is made available to you under the terms of Version 2 of
+# the GNU General Public License. A copy of that license should have
+# been provided with this software, but in any event can be snarfed
+# from www.gnu.org.
+#
+# This work is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+#
+#
+# CONTRIBUTION SUBMISSION POLICY:
+#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# END BPS TAGGED BLOCK }}}
+
+package RT::Action::RTIR_SetSLAFromPriority;
+use strict;
+use warnings;
+use base 'RT::Action::RTIR';
+
+=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' ) || ();
+
+ my $sla = $priority_to_sla->{ $self->TicketObj->Priority} || $priority_to_sla->{ $self->TicketObj->PriorityAsString};
+
+ if ( $sla ) {
+ # Nothing to do
+ if ( $self->TicketObj->SLA && $self->TicketObj->SLA eq $sla ) {
+ return 1;
+ }
+
+ my ($ret, $msg) = $self->TicketObj->SetSLA( $sla );
+ 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_CreateOrPriorityChange.pm b/lib/RT/Condition/RTIR_CreateOrPriorityChange.pm
new file mode 100644
index 00000000..acc43c03
--- /dev/null
+++ b/lib/RT/Condition/RTIR_CreateOrPriorityChange.pm
@@ -0,0 +1,74 @@
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
+# <sales at bestpractical.com>
+#
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
+#
+# This work is made available to you under the terms of Version 2 of
+# the GNU General Public License. A copy of that license should have
+# been provided with this software, but in any event can be snarfed
+# from www.gnu.org.
+#
+# This work is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+#
+#
+# CONTRIBUTION SUBMISSION POLICY:
+#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# END BPS TAGGED BLOCK }}}
+package RT::Condition::RTIR_CreateOrPriorityChange;
+use strict;
+use warnings;
+use base 'RT::Condition::RTIR';
+
+=head1 RTIR_CreateOrPriorityChange
+
+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 1;
+ }
+ return;
+}
+
+1;
+
-----------------------------------------------------------------------
More information about the rt-commit
mailing list