[Bps-public-commit] RT-Extension-MandatoryOnTransition branch, check-for-to-field, created. 0.18-1-gaf1c479

Craig Kaiser craig at bestpractical.com
Tue Jul 2 13:19:22 EDT 2019


The branch, check-for-to-field has been created
        at  af1c47963cb8a833cc0191593f4a49cbff385905 (commit)

- Log -----------------------------------------------------------------
commit af1c47963cb8a833cc0191593f4a49cbff385905
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Mon Jul 1 17:20:41 2019 -0400

    Check if we have a 'To' field before checking mandatory conditions
    
    If there is no 'To' field then a error will default to complaining that
    some field(s) are mandatory on queue change, even when the change being
    made is not a queue change.

diff --git a/html/Callbacks/RT-Extension-MandatoryOnTransition/Ticket/Update.html/BeforeUpdate b/html/Callbacks/RT-Extension-MandatoryOnTransition/Ticket/Update.html/BeforeUpdate
index 171893f..70c49be 100644
--- a/html/Callbacks/RT-Extension-MandatoryOnTransition/Ticket/Update.html/BeforeUpdate
+++ b/html/Callbacks/RT-Extension-MandatoryOnTransition/Ticket/Update.html/BeforeUpdate
@@ -8,7 +8,7 @@ $results => []
 my $errors_ref = RT::Extension::MandatoryOnTransition->CheckMandatoryFields(
     ARGSRef => $ARGSRef,
     Ticket  => $TicketObj,
-    To      => $ARGSRef->{'Status'},
+    To      => $ARGSRef->{'Status'} || $ARGSRef->{'DefaultStatus'},
 );
 
 if (@$errors_ref) {
diff --git a/lib/RT/Extension/MandatoryOnTransition.pm b/lib/RT/Extension/MandatoryOnTransition.pm
index 97bf52c..4d5d4a1 100644
--- a/lib/RT/Extension/MandatoryOnTransition.pm
+++ b/lib/RT/Extension/MandatoryOnTransition.pm
@@ -479,14 +479,16 @@ sub CheckMandatoryFields {
     }
 
     # Some convenience variables set depending on what gets passed
-    my ($CFs, $CurrentUser);
+    my ($CFs, $CurrentUser, $queue_current);
     if ( $args{'Ticket'} ){
         $CFs = $args{'Ticket'}->CustomFields;
         $CurrentUser = $args{'Ticket'}->CurrentUser();
+        $queue_current = $args{'Ticket'}->QueueObj->Name;
     }
     elsif ( $args{'Queue'} ){
         $CFs = $args{'Queue'}->TicketCustomFields;
         $CurrentUser = $args{'Queue'}->CurrentUser();
+        $queue_current = $args{'Queue'}->Name;
     }
     else{
         $RT::Logger->error("CheckMandatoryFields requires a Ticket object or a Queue object");
@@ -503,6 +505,8 @@ sub CheckMandatoryFields {
     return \@errors unless @$core or @$cfs or @$roles;
 
     my $transition =  ($args{'From'} ||'') ne ($args{'To'} || '') ? 'Status' : 'Queue';
+    return \@errors unless ( $field_label{'Queue'} && $queue_current ne $field_label{'Queue'} )
+        || $args{'To'} and defined $args{'From'} ? $args{'From'} ne $args{'To'} : 1;
 
     # If we were called from Modify.html (Basics) or ModifyAll.html
     # (Jumbo), where the SubmitTicket button goes by 'Save Changes',

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


More information about the Bps-public-commit mailing list