Mailing List Archive

rtir branch 5.0/use-current-interface-for-how-reported2 created. 5.0.3-12-g12713ca2
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 12713ca28e67c45b5060180f179345c415951dbe (commit)

- Log -----------------------------------------------------------------
commit 12713ca28e67c45b5060180f179345c415951dbe
Author: Ronaldo Richieri <ronaldo@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..b1079993 100644
--- a/docs/UPGRADING-5.0
+++ b/docs/UPGRADING-5.0
@@ -242,4 +242,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@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@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
_______________________________________________
rt-commit mailing list
rt-commit@lists.bestpractical.com
https://lists.bestpractical.com/mailman/listinfo/rt-commit