Thank you.  I'll give this a try tomorrow.  I figured there had to be a
simpler way to get what I wanted, but I am just fumbling around trying to
figure things out.  It actually took me almost 5 hours of trial and error
to get what I have working.

John







On 7/7/11 7:25 PM, "Thomas Sibley" <t...@bestpractical.com> wrote:

>On 07/07/2011 07:21 PM, John Alberts wrote:
>> Thanks for the tip.  It led me in the right direction and I ended up
>>with
>> this, which finally works.
>> 
>> my $T_Obj = $self->TicketObj;
>>    my $a = RT::Attachments->new($self->TransactionObj->CurrentUser);
>>    my $b = RT::Attachments->new($self->TransactionObj->CurrentUser);
>>    my $AttachObj = $self->TransactionObj->Attachments;
>>    while ( $a = $AttachObj->Next ) {
>>   $b = $a;
>>   next unless $a->Filename eq "env-vars.txt";
>>            }
>>    my $content = $b->Content;
>
>The above will fail when env-vars.txt isn't the last attachment RT
>parsed.  Try this (untested) much simpler version:
>
>    my $attachments = $self->TransactionObj->Attachments;
>    my $content;
>    while (my $attach = $attachments->Next) {
>        if ($attach->Filename eq "env-vars.txt") {
>            $content = $attach->Content;
>            last; # we found it, no need to keep looking
>        }
>    }
>    # use $content for whatever you'd like here
>
>There are better, faster ways to do this than looping over the
>attachments, but looping is the easiest to understand.
>
>Thomas
>
>--------
>2011 Training: http://bestpractical.com/services/training.html


--------
2011 Training: http://bestpractical.com/services/training.html

Reply via email to