Scrip changes requestor, but correspondence sent to original email

For a onCreate Condition a scrip deletes all original requestors and sets a new one. The next scrip sends a onCreate notification, however it sends the email to the old (deleted) requestor.

  • All further correspondance is sent correctly (when created via the webinterface).
  • Order of the Scrips is set correctly.

Simplified code:

if (some condition) {

  # Remove all requestors
  for ($self->TicketObj->Requestors->MemberEmailAddresses) {
      $self->TicketObj->DeleteWatcher (
        Type  => 'Requestor',
        Email => $_,
        Silent => 0
  );

  # Add new requestor
  $self->TicketObj->AddWatcher (
    Type  => "Requestor",
    Email => $email_new
  );

}

return 1;

I believe the scrips will all run for the state of the ticket that they were kicked off in, so changing the requestor in a scrip won’t affect scrips that are already kicked off to run.

There is the batch mode that would allow you to check if changes are made but off the top of my head, I am not sure how you would change the email recipients.

Maybe you could write an email plugin or overlay that handles setting the requestor on ticket initial create?

I was not able to find another solution to this problem.
I am now rewriting the From: header within the MTA, just before the mail is passed over to RT.