TransactionBatch

Hi,

I have a small scrip that changes a custom field to “IT” in case a correspondence is added to a ticket by a user who is not member of the IT group:

Condition: On Correspond
Action: User Definded
Template: Blank
Stage: TransactionCreate

Preparation: return 1;
Cleanup code:

my $group = ‘IT’;

my $PrincipalObj = RT::Principal->new( $self->TransactionObj->CreatorObj );
$PrincipalObj->Load( $self->TransactionObj->CreatorObj->Id );

my $groupobj = RT::Group->new($self->TransactionObj->CreatorObj );
$groupobj->LoadUserDefinedGroup($group);
my $HasMember = $groupobj->HasMemberRecursively( $PrincipalObj );

if (! $HasMember) {
$RT::Logger->info(“Ticket changed by admin”);

my $CFName = 'Wartet auf';
my $DefaultValue = 'IT';
my $RecTransaction = 1;

my $QueueObj = $self->TicketObj->QueueObj;
my $CFObj = RT::CustomField->new( $QueueObj->CurrentUser );
$CFObj->LoadByNameAndQueue( Name => $CFName, Queue => 0 );
unless( $CFObj->id ) {
  $RT::Logger->warning( "$CFName doesn't exist, Queue -". $QueueObj->Name ."-" );
  return undef; 
}

if ( $self->TicketObj->FirstCustomFieldValue( $CFObj->id ) eq "User" ) {
   my( $st, $msg ) = $self->TicketObj->AddCustomFieldValue(
					  Field => $CFObj->id,
					  Value => $DefaultValue,
					  RecordTransaction => $RecTransaction );
   unless( $st ) {
      $RT::Logger->warning( "Couldn't set $DefaultValue as value for CF $CFName:". $msg );
      return undef;
    }
}

}

My problem: If the custom field “Wartet auf” is shown in the Update page it sometimes happens that the scrip changes the field to “IT” and a later transaction changes it back to the former value (the one shown in the update field):

Do. 22. Jun. 2006, 08:45:00 t.user - Wartet auf IT changed to User

Do. 22. Jun. 2006, 08:45:00 RT_System - Wartet auf User changed to IT

Do. 22. Jun. 2006, 08:44:59 RT_System - Ausgehende Mail gespeichert [Zeige]

Do. 22. Jun. 2006, 08:44:59 RT_System - Ausgehende Mail gespeichert [Zeige]

Do. 22. Jun. 2006, 08:44:58 t.user - Correspondence added [Antworten] [Kommentar]

I suspect the update page created several transactions, one for the Correspondence and maybe one for custom field? If so, I thought that TransactionBatch would be the solution. So I changed the scrip to TransactionBatch stage and nothing happens, it simply does not fire (yes UseTransactionBatch in RT_SiteConfig is set and apache restarted). Why?

Kind regards,
JP