Solved: Warning for Note External

English! place to talk about development, programming and coding
Post Reply
RBehr
Znuny expert
Posts: 167
Joined: 26 Jan 2011, 13:23
Znuny Version: 3.0.7
Real Name: Rod Behr
Company: Impact
Location: London, United Kingdom
Contact:

Solved: Warning for Note External

Post by RBehr »

My users, worried that they may create a "Note - external" by mistake, want to be warned when they select "Note - external". Just a little JavaScript alert would do the trick.

How and where would I implement this?
Last edited by RBehr on 14 Dec 2011, 16:46, edited 1 time in total.
Rod Behr
Software Design Manager and Database Analyst | Impact Audiovisual | London
Installation: OTRS 3.0.7, Apache 2, Strawberry Perl 5 on Ubuntu 10.04.3 Server with separate MySQL Server, also on Ubuntu 10.04.3
RBehr
Znuny expert
Posts: 167
Joined: 26 Jan 2011, 13:23
Znuny Version: 3.0.7
Real Name: Rod Behr
Company: Impact
Location: London, United Kingdom
Contact:

Re: Warning for Note External

Post by RBehr »

Any news on this question?
Rod Behr
Software Design Manager and Database Analyst | Impact Audiovisual | London
Installation: OTRS 3.0.7, Apache 2, Strawberry Perl 5 on Ubuntu 10.04.3 Server with separate MySQL Server, also on Ubuntu 10.04.3
RBehr
Znuny expert
Posts: 167
Joined: 26 Jan 2011, 13:23
Znuny Version: 3.0.7
Real Name: Rod Behr
Company: Impact
Location: London, United Kingdom
Contact:

Re: Warning for Note External

Post by RBehr »

Hello?
Rod Behr
Software Design Manager and Database Analyst | Impact Audiovisual | London
Installation: OTRS 3.0.7, Apache 2, Strawberry Perl 5 on Ubuntu 10.04.3 Server with separate MySQL Server, also on Ubuntu 10.04.3
Alexander Halle
Znuny expert
Posts: 296
Joined: 04 Jul 2010, 17:49
Znuny Version: 3.1.x
Real Name: Alexander Halle
Company: radprax MVZ GmbH
Location: Wuppertal
Contact:

Re: Warning for Note External

Post by Alexander Halle »

I think you have to modify the corresponding DTL-Files. There should be one for each action screen (like adding a note or writing an email, see URL for screen for the right module). There you have to place the javascript validation code.
Alexander Halle System: OTRS 3.1.x, Ubuntu 10.04.x LTS, MySQL 5.1.x, Apache 2.2.x
OTRS Community Links: User Meetings, Projects
RBehr
Znuny expert
Posts: 167
Joined: 26 Jan 2011, 13:23
Znuny Version: 3.0.7
Real Name: Rod Behr
Company: Impact
Location: London, United Kingdom
Contact:

Re: Warning for Note External

Post by RBehr »

You are correct. The relevant .dtl file is /opt/otrs/Kernel/output/HTML/Standard/AgentTicketNote.dtl. My point is, however, that this file is generated from /opt/otrs/Kernel/Modules/AgentTicketNote.pm and a number of other Perl script files. The .dtl gives the basic HTML layout but not, crucially, the entries for the <select><option> HTML tags, and I need to create a script that reacts to the selection of a specific value in a <select> list.

Also, this would not just be for a note, but for any form which exposes the note-type field (potentially a large number, depending onSysConfig settings, including Pending, Change Queue, Close, etc.)

Is there a recommended method of adding JavaScript in this method? I would rather not go hard-coding it into the .dtl file unless I have to.

Thanks
Rod Behr
Software Design Manager and Database Analyst | Impact Audiovisual | London
Installation: OTRS 3.0.7, Apache 2, Strawberry Perl 5 on Ubuntu 10.04.3 Server with separate MySQL Server, also on Ubuntu 10.04.3
Alexander Halle
Znuny expert
Posts: 296
Joined: 04 Jul 2010, 17:49
Znuny Version: 3.1.x
Real Name: Alexander Halle
Company: radprax MVZ GmbH
Location: Wuppertal
Contact:

Re: Warning for Note External

Post by Alexander Halle »

You can try to add an "output filter".

An output filter can modify the HTML code created by the perl module, I think via "$Output".

Please see Kernel/Output/HTML/OutputFilterTextURL.pm for an example, this module makes links clickable by adding the HTML tags.
And http://doc.otrs.org/developer/2.4/en/ht ... tputfilter.

You could even try to inject your javascript code right into the created HTML code that shows the select list via such an output filter. For example check per RegEx if there is an article type in the HTML code. If yes inject the javascript code which checks for "note external" and then shows the confirm popup. If the user selects "cancel" your code would stop sending the form data so that no note of type external is created.

P.S.
Since you usally publish your solutions for others I asked in the community for the solution to support you. So not all of the above is from me directly, but I tried to explain it as good as I can.
Alexander Halle System: OTRS 3.1.x, Ubuntu 10.04.x LTS, MySQL 5.1.x, Apache 2.2.x
OTRS Community Links: User Meetings, Projects
RBehr
Znuny expert
Posts: 167
Joined: 26 Jan 2011, 13:23
Znuny Version: 3.0.7
Real Name: Rod Behr
Company: Impact
Location: London, United Kingdom
Contact:

Re: Warning for Note External

Post by RBehr »

That is very kind of you, Alexander, thank you. I will have a look and report back.
Rod Behr
Software Design Manager and Database Analyst | Impact Audiovisual | London
Installation: OTRS 3.0.7, Apache 2, Strawberry Perl 5 on Ubuntu 10.04.3 Server with separate MySQL Server, also on Ubuntu 10.04.3
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Warning for Note External

Post by crythias »

Kernel/Output/HTML/Layout.pm is called for BuildSelection

It includes an optional entry for "OnChange" => 'javascript',

Round about line 1331, Kernel/Modules/AgentTicketActionCommon.pm starts getting the DefaultNoteTypes

Later, it builds the selection..

Code: Select all

        $Param{ArticleTypeStrg} = $Self->{LayoutObject}->BuildSelection(
            Data => \%NoteTypes,
            Name => 'ArticleTypeID',
            %ArticleType,
        );
It seems reasonable to add something like

Code: Select all

OnChange => 'if (this.options[this.selectedIndex].value=='10') { alert('external') };',
after Name.

'10' is the id for note-external
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
RBehr
Znuny expert
Posts: 167
Joined: 26 Jan 2011, 13:23
Znuny Version: 3.0.7
Real Name: Rod Behr
Company: Impact
Location: London, United Kingdom
Contact:

Re: Warning for Note External

Post by RBehr »

Crythias, again you ride to the rescue. Nice, elegant solution. Thank you.
Rod Behr
Software Design Manager and Database Analyst | Impact Audiovisual | London
Installation: OTRS 3.0.7, Apache 2, Strawberry Perl 5 on Ubuntu 10.04.3 Server with separate MySQL Server, also on Ubuntu 10.04.3
Post Reply