If only the articles were created with attachments..

English! place to talk about development, programming and coding
Post Reply
eandrex
Znuny expert
Posts: 213
Joined: 04 Nov 2012, 23:58
Znuny Version: OTRS 4.x
Real Name: Esteban
Company: NORTON DE COLOMBIA

If only the articles were created with attachments..

Post by eandrex »

Hi,

so today i client contacted me to implement a feature to add a "CC" field when a customer is creating a ticket in the web interface(customer.pl).. in that way, they could send a copy of the ticket to their leader..

at first i tried creating a dynamic field for "tickets".. but then i realised that

Code: Select all

$Self->{TicketObject}->ArticleFirstArticle()
would return nothing because the article is created after the "TicketCreate event".. so i changed the dynamic field for "Articles"..after doing so,ArticleFirstArticle() worked just fine..but then i thought..hmm what if the user sends a ticket with attachments? ok lets send them in the email too.. unfortunately, it doesnt work like that and ill tell you why:

I had this snippet

Code: Select all

my %ArticleAttachmentIndex = $Self->{TicketObject}->ArticleAttachmentIndex(
        ArticleID => $Article{ArticleID},
        Article => \%Article,
        StripPlainBodyAsAttachment => 1,
        UserID => 1,
    );
    my @EmailAttachments = ();
    if( %ArticleAttachmentIndex ){
        foreach my $AttachmentID(keys %ArticleAttachmentIndex){
            my %Attachment = $Self->{TicketObject}->ArticleAttachment(
                ArticleID => $Article{ArticleID},
                FileID => $AttachmentID,
                UserID => 1,
            );
            next if !%Attachment;

            push @EmailAttachments,{
                Filename => $Attachment{Filename},
                Content => $Attachment{Content},
                ContentType => $Attachment{ContentType},
            };
        }
    }
thinking that @EmailAttachments would pouplate with the attachments that the user sent...but it was not the case.. when i tested the coded, the email didnt have any attachments :? and after looking into OTRS coded, i saw why

https://github.com/OTRS/otrs/blob/rel-3 ... ge.pm#L618

the attachments are being uploaded after the "ArticleDynamicFieldUpdate" event... so thats right, nothing i could do.. and im not goint to modify OTRS Core code under any circumstance.

so yeah, thats my story..i guess ill have to implement that with the help "Generic Agent". A filter with something like:

Tickets with 5 minutes old would do the trick.


thats it, i just wanted to share my experience :D
Post Reply