Edit mail content before Notification

I guess this may not be feasible as there is no reply? I’m trying to understand this issue and thought I would share my investigation in case it shed light to someone.

I checked which transactions and attachments are being logged upon making a new requstor correspondence and here is what sequentially happens with transactions and attachments in the database for the last correspondence test which includes string XXX in the email body:

  • SQL order used: select created,id,transactionid, subject,contenttype,contentencoding,content from attachments where transactionid IN (select id from transactions where objectid=56014 and objecttype=‘RT::Ticket’) order by created;
  • Results:
    |Created|id|transactionid|subject|contenttype|contentencoding|content|
    | — | — | — | — | — | — | — |
    |14/01/2019 14:48|3426343|1677793|Re: [Thermo NGS Support #56014] test RT|multipart/alternative|||
    |14/01/2019 14:48|3426345|1677793||text/html|none|<html>(…)
    <div>XXX</div>
    (…)</html>|
    |14/01/2019 14:48|3426344|1677793||text/plain|none|YYY|
    |14/01/2019 14:48|3426346|1677795|Re: [Thermo NGS Support #56014] test RT|text/plain|none|Requestor has replied to the following ticket:
    XXX|

So I can make multiple observations from above query results:

  1. the first 3 attachments have the same transactionid => test/plain attachment id = 1677793.
  2. the text/plain attachment id 3426344 does have the modified string where XXX became YYY (the Scrip worked here)
  3. the last attachment - notification sent to the owner - has a new transaction_id => 1677795 and String XXX is not replaced by YYY here - does this mean the content is read from memory rather than from the DB on that transaction?
  4. the text/html attachment still has XXX although I’m using both calls below in the scrips:
    $self->TransactionObj->ContentObj->__Set( Field => ‘Content’, Type => “text/html”, Value => $htmlContent);
    $self->TransactionObj->ContentObj->__Set( Field => ‘Content’, Type => “text/plain”, Value => $content);

Any pointers would be greatly appreciated… Many thanks!