Make scrip run once per ticket, and only once

I have a scrip that emails custom field values to a junk email address so
that the values show up in transactions. This is necessary for various
reasons I won’t bother you with here.

However, the current conditions I have allow the scrip to run several times
per ticket. How can I stop this?

This is the custom condition I wrote:

my $Ticket = $self->TicketObj;
return 0 unless $self->TransactionObj->Type eq ‘CustomField’;
return 0 unless $Ticket->FirstCustomFieldValue(‘Keywords’);
return 1;

Because there are several custom fields being emailed, with each one
activating all the custom field scrips, this scrip is executed many times
per ticket.

View this message in context: http://requesttracker.8502.n7.nabble.com/Make-scrip-run-once-per-ticket-and-only-once-tp57454.html

I have a scrip that emails custom field values to a junk email address so
that the values show up in transactions. This is necessary for various
reasons I won’t bother you with here.

However, the current conditions I have allow the scrip to run several times
per ticket. How can I stop this?

This is the custom condition I wrote:

my $Ticket = $self->TicketObj;
return 0 unless $self->TransactionObj->Type eq ‘CustomField’;
return 0 unless $Ticket->FirstCustomFieldValue(‘Keywords’);
return 1;

Because there are several custom fields being emailed, with each one
activating all the custom field scrips, this scrip is executed many times
per ticket.

Either have your scrip set some other CF to track if the mail went
out, or only succeed if ALL your custom fields are set. However, this
would still allow it to run more than once, so you really need some
other CF or an Attribute to track state.

You may want to explain why “the values show up in transactions” is
important since this sounds a bit like you’re running into the XY
problem.

-kevin