[Rt-commit] rtir branch 5.0/use-current-interface-for-how-reported2 created. 5.0.3-12-g980b08fc

BPS Git Server git at git.bestpractical.com
Thu Mar 23 16:54:23 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rtir".

The branch, 5.0/use-current-interface-for-how-reported2 has been created
        at  980b08fc0d7f95a50ec758211c308068527264b9 (commit)

- Log -----------------------------------------------------------------
commit 980b08fc0d7f95a50ec758211c308068527264b9
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Thu Jan 19 16:08:53 2023 -0300

    Document the changes to RTIR_SetHowReported in UPGRADING

diff --git a/docs/UPGRADING-5.0 b/docs/UPGRADING-5.0
index b7c43498..f7c4e507 100644
--- a/docs/UPGRADING-5.0
+++ b/docs/UPGRADING-5.0
@@ -121,6 +121,19 @@ This feature was removed in RTIR 4.0, but has been restored in RTIR 5.0.0. It
 has also been updated to allow the queue for each section to be selected on
 the create page.
 
+=item *
+
+Since RTIR 5.0.4, RTIR_SetHowReported.pm Action has new possible options for the
+"How Reported" Custom Field but they are not updated automatically.
+To use the new options, update the "How Reported" Custom Field by adding the new
+options:
+
+    "API", "CLI", "REST", "REST2" and "Web".
+
+The full default options list is:
+
+    "API", "CLI", "Email", "REST", "REST2", "Telephone", "Web" and "Other"
+
 =back
 
 =head1 UPGRADING FROM RTIR 5.0.0 AND EARLIER
@@ -242,4 +255,25 @@ moving the scrip to Batch mode may restore the previous behavior.
 
 =back
 
+=head1 UPGRADING FROM 5.0.3 AND EARLIER
+
+=over 4
+
+=item * "How Reported" no longer defaults to Email
+
+In previous versions of RTIR, L<RT::Action::RTIR_SetHowReported> automatically
+set the "How Reported" custom field on Incident Reports to "Email" if no
+value was provided. In RTIR 5.0.4 we updated this action to get the value
+from RT's L<RT::CurrentInterface> method, so it will automatically be set
+to values like "Web" or "REST2" if a ticket is created that way rather than
+always "Email".
+
+If you prefer defaulting to "Email", you can disable this scrip and set "Email"
+as a default value in the Incident Reports queue configuration.
+
+If you want to see new values set automatically, you can update you values
+list for "How Reported" to include these new values:
+
+    "API", "CLI", "REST", "REST2", and "Web"
+
 =cut

commit 212f70453042a134f11fe30faf977c6c7e8b7184
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Thu Mar 23 11:48:41 2023 -0400

    Create How Reported with valid values of CurrentInterface

diff --git a/etc/initialdata b/etc/initialdata
index 1b720a2d..986cd5fa 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -104,9 +104,14 @@ die "Please add RT::IR to your Plugins configuration before initializing the dat
         Description =>
             'How the incident was reported for Incident Reports RTIR queue',
         Values => [
-            { Name => "Email",     SortOrder => 1 },
-            { Name => "Telephone", SortOrder => 2 },
-            { Name => "Other",     SortOrder => 3 },
+            { Name => "API",       SortOrder => 1 },
+            { Name => "CLI",       SortOrder => 2 },
+            { Name => "Email",     SortOrder => 3 },
+            { Name => "REST",      SortOrder => 4 },
+            { Name => "REST2",     SortOrder => 5 },
+            { Name => "Web",       SortOrder => 6 },
+            { Name => "Telephone", SortOrder => 7 },
+            { Name => "Other",     SortOrder => 8 },
         ]
     },
     {   Name        => 'Reporter Type',

commit 73df0716b6e323ba9b09c2c5328b0383013ccfe4
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Thu Jan 19 17:06:40 2023 -0300

    Set "How Reported" CF from CurrentInterface
    
    Fixes: I#32162

diff --git a/lib/RT/Action/RTIR_SetHowReported.pm b/lib/RT/Action/RTIR_SetHowReported.pm
index b143745e..4b3a5d78 100644
--- a/lib/RT/Action/RTIR_SetHowReported.pm
+++ b/lib/RT/Action/RTIR_SetHowReported.pm
@@ -51,9 +51,21 @@ use strict;
 use warnings;
 use base 'RT::Action::RTIR';
 
-=head2 Commit
+=head1 NAME
 
-If the HowReported field isn't set, assume it's email.
+RT::Action::RTIR_SetHowReported
+
+=head1 DESCRIPTION
+
+Sets the "How Reported" custom field based on the interface RT reports
+was used to create the ticket. See L<RT/CurrentInterface> for the list of
+interfaces RT can detect.
+
+This action does nothing if the interface is not in the list of values
+for "How Reported", so you can safely remove values in the custom field
+configuration if some don't make sense for your reporting.
+
+This action also does nothing if a value is already set.
 
 =cut
 
@@ -64,10 +76,29 @@ sub Commit {
     $cf->LoadByNameAndQueue(Queue => $self->TicketObj->QueueObj->Id, Name => 'How Reported');
     return unless $cf->Id;
 
+    # Get the current values of this CF
     my $Values = $self->TicketObj->CustomFieldValues( $cf->id );
-    unless ( $Values->Count ) {
-        $self->TicketObj->AddCustomFieldValue( Field => $cf->id, Value => "Email" );
+
+    # Don't overwrite if it's already set
+    return 1 if $Values->Count;
+
+    # Get acceptable values for this CF
+    my $ValuesObj = $cf->ValuesObj();
+
+    # Verify that the current interface is a valid value
+    while ( my $Value = $ValuesObj->Next ) {
+        if ( $Value->Name eq RT->CurrentInterface() ) {
+            my ($ok, $msg) = $self->TicketObj->AddCustomFieldValue( Field => $cf->id, Value => RT->CurrentInterface() );
+
+            if ( not $ok ) {
+                RT->Logger->error("Unable to set custom field " . $cf->Name . ": $msg");
+                return 0;
+            }
+
+            return 1;
+        }
     }
+
     return 1;
 }
 

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


hooks/post-receive
-- 
rtir


More information about the rt-commit mailing list