[rt-users] Transaction->CustomFieldValues in scrips

Jesse Vincent jesse at bestpractical.com
Wed Aug 24 17:25:59 EDT 2005




On Wed, Aug 24, 2005 at 09:57:49PM +0200, MP wrote:
> Hi!
> 
> Anders Ekstrand írta:
> 
> >I have seen some postings about the same issue, but they all seems to
> >come down to that it doesn't work.
> >Is that really the case?
> > 
> >
> I gave up after i did not got any response to my last post about this. 
> If anybody would post "Hey, it's easy! I did it!", i would try harder...
> and i will try after every upgrade. There is Hope! ;)

So, the problem is that TransactionCustomFieldValues from the web UI
are set after the transaction is created. The attached patch fixes this,
but I'm not sure it feels clean enough to put into 3.4 core.

Jesse


> 
> best regards,
> 
> Peter Marton
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
> 
> Be sure to check out the RT Wiki at http://wiki.bestpractical.com
> 

-- 
-------------- next part --------------
=== lib/RT/Interface/Web.pm
==================================================================
--- lib/RT/Interface/Web.pm  (revision 13728)
+++ lib/RT/Interface/Web.pm  (local)
@@ -495,16 +495,23 @@
           foreach values %{ $args{ARGSRef}->{'UpdateAttachments'} };
     }
 
+    # Only pass custom field related args up the stack
+    my %cfargs = %{$args{'ARGSRef'}};
+    for (keys %cfargs) {
+        delete $cfargs{$_} unless /CustomField/;
+    }
+
+
     ## TODO: Implement public comments
     if ( $args{ARGSRef}->{'UpdateType'} =~ /^(private|public)$/ ) {
         my ( $Transaction, $Description, $Object ) = $args{TicketObj}->Comment(
             CcMessageTo  => $args{ARGSRef}->{'UpdateCc'},
             BccMessageTo => $args{ARGSRef}->{'UpdateBcc'},
             MIMEObj      => $Message,
-            TimeTaken    => $args{ARGSRef}->{'UpdateTimeWorked'}
+            TimeTaken    => $args{ARGSRef}->{'UpdateTimeWorked'},
+            %cfargs
         );
         push( @{ $args{Actions} }, $Description );
-        $Object->UpdateCustomFields( ARGSRef => $args{ARGSRef} ) if $Object;
     }
     elsif ( $args{ARGSRef}->{'UpdateType'} eq 'response' ) {
         my ( $Transaction, $Description, $Object ) =
@@ -512,10 +519,10 @@
             CcMessageTo  => $args{ARGSRef}->{'UpdateCc'},
             BccMessageTo => $args{ARGSRef}->{'UpdateBcc'},
             MIMEObj      => $Message,
-            TimeTaken    => $args{ARGSRef}->{'UpdateTimeWorked'}
+            TimeTaken    => $args{ARGSRef}->{'UpdateTimeWorked'},
+            %cfargs
           );
         push( @{ $args{Actions} }, $Description );
-        $Object->UpdateCustomFields( ARGSRef => $args{ARGSRef} ) if $Object;
     }
     else {
         push(
=== lib/RT/Record.pm
==================================================================
--- lib/RT/Record.pm  (revision 13728)
+++ lib/RT/Record.pm  (local)
@@ -65,10 +65,11 @@
 =cut
 
 package RT::Record;
+use RT::Base;
 use RT::Date;
+use RT::Transaction;
 use RT::User;
 use RT::Attributes;
-use RT::Base;
 use DBIx::SearchBuilder::Record::Cachable;
 
 use strict;
@@ -1426,23 +1427,16 @@
 	$new_ref = $new_ref->Id if ref($new_ref);
     }
 
-    require RT::Transaction;
+    delete $args{id};
+
     my $trans = new RT::Transaction( $self->CurrentUser );
     my ( $transaction, $msg ) = $trans->Create(
-	ObjectId  => $self->Id,
+        %args, # push up basic data and custom fields
+        ObjectId  => $self->Id,
 	ObjectType => ref($self),
-        TimeTaken => $args{'TimeTaken'},
-        Type      => $args{'Type'},
-        Data      => $args{'Data'},
-        Field     => $args{'Field'},
-        NewValue  => $args{'NewValue'},
-        OldValue  => $args{'OldValue'},
         NewReference  => $new_ref,
         OldReference  => $old_ref,
         ReferenceType => $ref_type,
-        MIMEObj   => $args{'MIMEObj'},
-        ActivateScrips => $args{'ActivateScrips'},
-        CommitScrips => $args{'CommitScrips'},
     );
 
     # Rationalize the object since we may have done things to it during the caching.
=== lib/RT/Ticket_Overlay.pm
==================================================================
--- lib/RT/Ticket_Overlay.pm  (revision 13728)
+++ lib/RT/Ticket_Overlay.pm  (local)
@@ -2394,11 +2394,9 @@
 
     #Record the correspondence (write the transaction)
     my ( $Trans, $msg, $TransObj ) = $self->_NewTransaction(
+             %args, # basic info, custom fields    
              Type => $args{'NoteType'},
              Data => ( $args{'MIMEObj'}->head->get('subject') || 'No Subject' ),
-             TimeTaken => $args{'TimeTaken'},
-             MIMEObj   => $args{'MIMEObj'}, 
-             CommitScrips => $args{'CommitScrips'},
     );
 
     unless ($Trans) {
=== lib/RT/Transaction_Overlay.pm
==================================================================
--- lib/RT/Transaction_Overlay.pm  (revision 13728)
+++ lib/RT/Transaction_Overlay.pm  (local)
@@ -150,8 +150,7 @@
     my $id = $self->SUPER::Create(%params);
     $self->Load($id);
     $self->_Attach( $args{'MIMEObj'} ) if defined $args{'MIMEObj'};
-
-
+    $self->UpdateCustomFields(%args);
     #Provide a way to turn off scrips if we need to
         $RT::Logger->debug('About to think about scrips for transaction #' .$self->Id);
     if ( $args{'ActivateScrips'} and $args{'ObjectType'} eq 'RT::Ticket' ) {


More information about the rt-users mailing list