Hi Rick,

For the complete history of a ticket you need to first load the tickets 
transactions and then select those you want to cycle through - then cycle 
through them and only printing the create and correspond content.

In the template try something like this code block:
{
    # Select which transactions to cycle through
    my $transactions = $Ticket->Transactions;
    $transactions->Limit( FIELD => 'Type', VALUE => 'Create' );
    $transactions->Limit( FIELD => 'Type', VALUE => 'Correspond', 
ENTRYAGGREGATOR => 'OR', OPERATOR => '=' );

    # Build the $content variable up - we'll be concatenating to this string 
below
    my $content;
    while (my $transaction = $transactions->Next) {
        my $attachments = $transaction->Attachments;
        while (my $attachment = $attachments->Next) {
            next unless $attachment->ContentType =~ 
m!^(text/html|text/plain|message|text$)!i;  # skip non-text stuff
            # Only include headers if they are present on the attachment
            $content .= defined $attachment->GetHeader('From') ? "From: 
".$attachment->GetHeader('From')."\n" : "";
            $content .= defined $attachment->GetHeader('To') ? "To: 
".$attachment->GetHeader('To')."\n" : "";
            $content .= defined $attachment->GetHeader('Subject') ? "Subject: 
".$attachment->GetHeader('Subject')."\n\n" : "";
            # Include the content of the attachment
            $content .= defined $attachment->OriginalContent ? 
$attachment->OriginalContent : "";
        }
    }
    return $content;
}

The above is not really tested code but I know the idea behind it works.

You've got me on the attachments.  I'd like to know more about that as well 
since attaching a file from a past update to a new a ticket update would be 
awesome.

Landon Stewart : [email protected]
Lead Specialist, Abuse and Security Management
Spécialiste principal, gestion des abus et sécurité
http://iweb.com : +1 (888) 909-4932

> On Mar 13, 2015, at 1:58 PM, Rick Zoerner <[email protected]> wrote:
> 
> Hi,
> 
> I have set up an approval process for invoices that is working perfectly up 
> to the paying part. However, to finish it up I have 2 tasks I can't figure 
> out on my own.
> 1)   I need to be able to send the entire "History" of the ticket in an 
> email, and,
> 2)   Attach any and all attachments from a particular custom field (of a 
> type=attach multiple documents).
> 
> So far, for this project, I have:
>   1- created a custom lifecycle using status changes to move a CapEx through 
> stages of authorization, acquisition, approval for payment and payment.
>   2- created custom templates for each status. Each status change triggers an 
> email using a template customized  for that person/stage in the process (i.e. 
> "Manager Approval", "IT Approval", "Finance Approval", "Acquire", 
> "ApproveToPay", "Coding", "Pay").
>   3- set up custom fields in the ticket to hold all the attachments needed 
> during the process in a consistent location. Quotes, invoices, etc.
> 
> The history display is particularly important because it is the audit trail 
> of all the approvals. Each approval level is just a drop-down custom field in 
> the ticket (approved/denied). It is the history that shows who flipped it to 
> "Approved" and the date/time stamp of when they did.
> 
> It works great for everybody in the sequence except the final stage - paying 
> the invoice(s).
> Finance has to open the ticket, print the web page to capture the history 
> (audit trail), then find the attachments and open/print each of them, then 
> look at the field where coding listed how to book the payable (GL account and 
> dollar amount), etc.
> 
> Since I am already sending them an email with a link to the ticket in it when 
> the status changes to "pay"... I would like to include in that email the full 
> history, a couple other custom fields I can capture easily (like the coding, 
> the original justification, etc.), and attach the invoices - one-stop 
> shopping for A/P. I just can't find anything to help me figure out how to 
> call out the entire ticket history.
> 
> Thanks in advance to anyone who has a ready answer for this - I'm NOT a 
> programmer at all, so I've spent several days looking through the 
> documentation and only barely able to understand a fraction of it. Please 
> speak to me as to a child - in Perl that would be an overly generous 
> appraisal of my ability.
> 
> -Rick
> 

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to