[rt-users] How to determine the value of a transaction custom field in ScripCondition
Jesse Vincent
jesse at bestpractical.com
Wed Mar 29 23:34:59 EST 2006
On Thu, Mar 30, 2006 at 11:40:38AM +0800, lwang wrote:
> Jesse,
> Did you post your patch in rt-user list or rt-devel list?
I think it was rt-devel. But I found and attached the patch. Thanks to
svk ;)
> Thanks.
>
> Jesse Vincent wrote:
> >Sometime around 6 months ago, I sent out mail with a patch to enable
> >this feature. It was way too hacky to be reasonable to include in the
> >core, but might be reasonable to use in your situation.
> >
> >
> >On Wed, Mar 29, 2006 at 11:43:20AM +0800, lwang wrote:
> >
> >>Hi there,
> >>
> >>I would like to check the value of a transaction custom field in a scrip
> >>condition to trigger an action.
> >>
> >>It seems, however, that I can't achieve this purpose. I found that the
> >>custom field for a transaction is not set when IsApplicable() is called.
> >>
> >>The transaction custom field is set in Interface/Web.pm separately after
> >>the transaction is created.
> >>
> >>Any alternatives are available?
> >>
> >>Any suggestion is appreciated.
> >>
> >>- Wang
> >>_______________________________________________
> >>http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
> >>
> >>Community help: http://wiki.bestpractical.com
> >>Commercial support: sales at bestpractical.com
> >>
> >>
> >>Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> >>Buy a copy at http://rtbook.bestpractical.com
> >>
> >>
> >>We're hiring! Come hack Perl for Best Practical:
> >>http://bestpractical.com/about/jobs.html
> >>
> >
> >
>
--
-------------- next part --------------
==== Patch <transaction-cfs-for-scrips.patch> level 1
Source: [No source]
Target: 1c347319-e6fb-0310-9638-ae390968d4ce:/local/rt-3.4:13754
Log:
This patch adds support for transaction custom field access in transaction scrips.
I'm not comfortable putting it in mainline
=== lib/RT/Interface/Web.pm
==================================================================
--- lib/RT/Interface/Web.pm (revision 13754)
+++ lib/RT/Interface/Web.pm (patch transaction-cfs-for-scrips.patch level 1)
@@ -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 13754)
+++ lib/RT/Record.pm (patch transaction-cfs-for-scrips.patch level 1)
@@ -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 13754)
+++ lib/RT/Ticket_Overlay.pm (patch transaction-cfs-for-scrips.patch level 1)
@@ -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 13754)
+++ lib/RT/Transaction_Overlay.pm (patch transaction-cfs-for-scrips.patch level 1)
@@ -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' ) {
==== BEGIN SVK PATCH BLOCK ====
Version: svk 1.09_01 (linux)
eJyFlU2MFEUUgFvc2Z+BBUMCG38SOtlGMDI73VXV1dVrMpmIQNCoiCsbBR2rq6qXlp7pSXcvP7E5
VO+GgxdWDDHBgwkH4w0OSki8mHgwGi4aEw9EOLMRgkQTY/yr7tlddsMCx06973vvVVW/2h1PPNe0
skbDzAzLzF4/8NL4+D6assN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nl1LQAySYOB4neLSa3TjlP9GS6243iVPejWE/vzgedTSdp1Nb9
QIRcp4yJJNGDzoqQhMVBNxmrVvdua+udKNVZ1FaalHqh0LvTaRp0pvQgLbA2DTph0BHValHsMkmN
+UlNQbUFWVlZowEyA4DeazNRPkDj4290AjWyEhpuxZl6nlTgYfUgxOKo+pieDrhhwaweRoyG9Tit
wbGl2WNAnFkMIgdabk1g36uZ0DJrLoakRgVUMwUTjpj4H1DIYco=
==== END SVK PATCH BLOCK ====
More information about the rt-users
mailing list