[Rt-commit] rtir branch 5.0/use-current-interface-for-how-reported created. 5.0.3-11-ge0976a66

BPS Git Server git at git.bestpractical.com
Wed Mar 1 12:33:17 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-reported has been created
        at  e0976a661661da02df5d1ffc15bd3cebca3f29f7 (commit)

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

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

diff --git a/lib/RT/Action/RTIR_SetHowReported.pm b/lib/RT/Action/RTIR_SetHowReported.pm
index b143745e..03c38b14 100644
--- a/lib/RT/Action/RTIR_SetHowReported.pm
+++ b/lib/RT/Action/RTIR_SetHowReported.pm
@@ -46,17 +46,30 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-package RT::Action::RTIR_SetHowReported;
-use strict;
-use warnings;
-use base 'RT::Action::RTIR';
+=head1 RTIR_SetHowReported
 
-=head2 Commit
+Sets the value of the interface used to create an incident report into the
+"How Reported" custom field, which by default can be one of the following:
 
-If the HowReported field isn't set, assume it's email.
+    "API", "CLI", "Email", "REST", "REST2", "Telephone", "Web" or "Other"
+
+This Action won't override the "How Reported" field if it's already defined.
+
+If you want to avoid this action to set a particular value into the "How Reported"
+custom field, remove the value from the list of valid values of the custom field
+in the administration.
+
+If you want to register a custom interface, you can do it by adding a new value
+to the "How Reported" custom field in the administration and creating a custom
+Scrip Action for identifying when the ticket was created using that interface.
 
 =cut
 
+package RT::Action::RTIR_SetHowReported;
+use strict;
+use warnings;
+use base 'RT::Action::RTIR';
+
 sub Commit {
     my $self = shift;
 
@@ -64,10 +77,23 @@ 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
+    foreach my $Value (@{$ValuesObj->ItemsArrayRef}) {
+        if ( $Value->Name eq RT::CurrentInterface() ) {
+                    $self->TicketObj->AddCustomFieldValue( Field => $cf->id, Value => RT::CurrentInterface() );
+                    return 1;
+        }
     }
+
     return 1;
 }
 

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

    Add more RT standard interfaces to "How Reported" CF
    
    Also update the UPGRADING-5.0 instruction to mention that the new
    "How Reported" values must be added manually to the Custom Field.

diff --git a/docs/UPGRADING-5.0 b/docs/UPGRADING-5.0
index b7c43498..5c9fd0cd 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
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',

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


hooks/post-receive
-- 
rtir


More information about the rt-commit mailing list