[SOLVED] Insert customer IP address into ticket?

Moderator: crythias

Post Reply
gears
Znuny newbie
Posts: 38
Joined: 24 Feb 2011, 18:29
Znuny Version: 5.0.14

[SOLVED] Insert customer IP address into ticket?

Post by gears »

My setup:
OTRS 3.0.6
Debian 6.0
Apache 2.2

Is there a way to have the IP address of the computer posting the ticket parsed and inserted into the ticket body or the portion of the interface which views the ticket? I know the IP addresses are all showing up in /var/log/apache2/access.log but I'm not sure where to take it from there. Most if not all users posting tickets in our system will be within our local network logged in with their AD accounts.

Assuming the above is possible, I'd also like to take it a step further. We have a network inventory web server separate from the OTRS web server and we would like a link to be inserted into each OTRS ticket or in the agent ticket view interface in a manner similar to this: "http://inventoryserver/default.aspx?ite ... 92.168.0.1"
so when viewing each ticket, there would also be a basic url or even just the plaintext link inserted somewhere like this:

Code: Select all

<A HREF="http://inventoryserver/default.aspx?item=quicksearch&q=[IP ADDRESS OF CUSTOMER]">Link to customer's computer info</A>
What would be the best way to go about this?


Thanks in advance for your help
:D
Last edited by gears on 03 Apr 2011, 07:54, edited 1 time in total.
OTRS 5.0.14 / Debian 7.11 x64 / Apache 2.2.22 / MySQL 14.14 Distrib 5.5.53
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Insert customer IP address into ticket?

Post by crythias »

via web interface, you'll want to modify Kernel/Output/HTML/Standard/CustomerTicketMessage.dtl (preferably in your own theme to survive updates).

Stick $Env{"REMOTE_ADDR"} somewhere relevant, whether that's in an input type=hidden in an enabled TicketFreeText or document.compose.RichText.value = "$Env{"REMOTE_ADDR"}";

For postmasterfilter ... email is quite a bit different to determine the true originating IP address and may not even be the box that's in trouble.
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
gears
Znuny newbie
Posts: 38
Joined: 24 Feb 2011, 18:29
Znuny Version: 5.0.14

Re: Insert customer IP address into ticket?

Post by gears »

Thanks for your reply. I've been researching a few areas of web development to expand my limited knowledge there and get a better understanding of your tips.

I added document.compose.RichText.value = "$Env{"REMOTE_ADDR"}"; to Kernel/Output/HTML/Standard/CustomerTicketMessage.dtl and this did indeed enter the visitor's ip address as text into the form they are filling out which is a step in the right direction.

I also really like the idea you suggested of having it submitted via type=hidden but I've been unable to get that to behave as intended due to my own ignorance. In sysconfig Core::TicketFreeText I enabled TicketFreeText1 and tried replacing one of the entries with ' "$Env{"REMOTE_ADDR"}"; but the result is that it just displays literally the text "$Env{"REMOTE_ADDR"}" in the customer interface rather than the variable. As an experiment I changed TicketFreeKey1 to $Env{"REMOTE_ADDR"} as well and it does display the visitor's ip address where "Product:" would normally appear for both the customer and agent interfaces, but the problem is that on the agent side, the agent is shown his own ip address rather than the ip of the customer who posted the ticket. I also tried hijacking the existing forms such as the "Subject" in Kernel/Output/HTML/Standard/CustomerTicketMessage.dtl to capture the the variable and this did then display the variable alongside the subject line in the interface but attempting to submit the form would just redirect to the same page with no submission. I don't yet grasp how to capture in a hidden manner an environment variable at the time the visitor posts the ticket and then present the contents of this variable to the agent viewing the ticket in a TicketFreeText value such as where "Product: Notebook" would be, for example. Any further info would be appreciated.
:oops:
OTRS 5.0.14 / Debian 7.11 x64 / Apache 2.2.22 / MySQL 14.14 Distrib 5.5.53
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Insert customer IP address into ticket?

Post by crythias »

somewhere near the end of CustomerTicketMessage.dtl, perhaps you might try:

Code: Select all

<script type="text/javascript">
      document.getElementById('TicketFreeText1').style.display = 'none';
      document.getElementById('LabelTicketFreeText1').style.display = 'none';
      document.getElementById('TicketFreeText1').value = "$Env{"REMOTE_ADDR"}";
</script>
where TicketFreeText1 is the enabled ticketfreetext you need.
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
gears
Znuny newbie
Posts: 38
Joined: 24 Feb 2011, 18:29
Znuny Version: 5.0.14

Re: Insert customer IP address into ticket?

Post by gears »

That worked great. I may submit a howto with your tips and the steps I went through along with a few other details to expand the possibilities

Thanks
:)
OTRS 5.0.14 / Debian 7.11 x64 / Apache 2.2.22 / MySQL 14.14 Distrib 5.5.53
mantrox
Znuny newbie
Posts: 3
Joined: 18 Jul 2011, 11:00
Znuny Version: 3.0.6

Re: [SOLVED] Insert customer IP address into ticket?

Post by mantrox »

Hi there,
i was trying to implement this function onto my OTRS code, but i cant seem to grasp where to put it on the file you indicated.

Is there some special configuration i need to do in order to enable the Tickefreetext fields so i can use the lines of code you supplied?

The only part of code that mentions TicketFreeText on my CustomerTicketMessage.dtl file is as follows:

Code: Select all

<!-- dtl:block:FreeText -->
                <div>
                    $Data{"TicketFreeKeyField"}
                    $Data{"TicketFreeTextField"}
                    <div id="TicketFreeText$Data{"Count"}UsedError" class="TooltipErrorMessage NoJavaScriptMessage$QData{"ServerError"}"><p>$Env{"REMOTE_ADDR"} $Text{"This field is required."}</p></div>
                    <div class="Clear">
					</div>
                </div>
<!-- dtl:block:FreeText -->
Thank you for your time, and pardon any language mistakes.
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: [SOLVED] Insert customer IP address into ticket?

Post by crythias »

You'll need to enable the TicketFreeText in SysConfig for the screens you want to show it.
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
mantrox
Znuny newbie
Posts: 3
Joined: 18 Jul 2011, 11:00
Znuny Version: 3.0.6

Re: [SOLVED] Insert customer IP address into ticket?

Post by mantrox »

My TicketFreeText1 is enabled and has the following structure:

Core::TicketFreeText
TicketFreeText1 /// Key - "IP Adress" ///Content - "" <-it's empty.

My objective here is that, every ticket automaticly inserts the user IP into the Content box.
But even though i insert the script you gave into CustomerTicketMessage.dtl it has no effect, as the drop box on TicketFreeText1 is still empty.

Im probably interpreting your method incorrectly.
Would you be so kind as to be more detailed in the procedure necessary to accomplish this?
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: [SOLVED] Insert customer IP address into ticket?

Post by crythias »

there's not a lot more than copy/pasting the code into the dtl.
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
yuri0001
Znuny superhero
Posts: 631
Joined: 17 Mar 2011, 14:40
Znuny Version: 5.0.6
Real Name: Yuri Kolesnikov
Location: Russia

Re: Insert customer IP address into ticket?

Post by yuri0001 »

Hi!
Is it works when customer login to OTRS through proxy-server? :?
Best regards Yuri Kolesnikov
OTRS 5.0.14, ITSM 5.0.14
SUSE 13.2, MariaDB 10.0.22(productive)
OTRS 5.0.14, ITSM 5.0.14(test)
StarDestroyer
Znuny newbie
Posts: 20
Joined: 05 Sep 2013, 22:26
Znuny Version: 5.0.x
Real Name: Jake
Company: Hilite International

Re: [SOLVED] Insert customer IP address into ticket?

Post by StarDestroyer »

This seems to be slightly different in OTRS v3.2... Here's what I did:
  1. Go to Admin -> Dynamic Fields and create a new "Ticket" field of the "text" type (I called mine "ipaddr").
  2. Go to Admin -> SysConfig and select "Ticket" from the dropdown. Load the "Frontend::Customer::Ticket::ViewNew" setting. Scroll down to the bottom to the "Ticket::Frontend::CustomerTicketMessage###DynamicField" setting and add an option with the Key of "ipaddr" with the content of 1.
  3. Go to Admin -> SysConfig and once again select "Ticket". Load the settings for "Frontend::Agent::Ticket::ViewZoom". Scroll down to the bottom to the "Ticket::Frontend::AgentTicketZoom###DynamicField" setting and once again add an option with the Key of "ipaddr" with the content of 1.
  4. Copy "Kernel/Output/HTML/Standard/CustomerTicketMessage.dtl" to "Custom/Kernel/Output/HTML/Standard/CustomerTicketMessage.dtl"
  5. Near the very bottom of the file, there's a <script> tag that runs the "Core.Customer.InitFocus();" function. Right beneath that line, add the following:

    Code: Select all

    document.getElementById("DynamicField_ipaddr").value = "$Env{"REMOTE_ADDR"}";
I chose to leave my IP Address field visible, but you could hide it with some more JavaScript and/or with CSS.

Also, if you want to display it on more screens than just the new ticket customer screen and the ticket zoom agent screen, you can repeat the above steps for Frontend::Customer::Ticket::ViewNew and Frontend::Agent::Ticket::ViewZoom.
OTRS 5.0.x on CentOS 6 w/MySQL Database
PriteshP23
Znuny newbie
Posts: 98
Joined: 02 Sep 2014, 23:01
Znuny Version: 4.0.9-02

Re: [SOLVED] Insert customer IP address into ticket?

Post by PriteshP23 »

First of all, thank you all for this great post.

@StarDestroyer
4. Copy "Kernel/Output/HTML/Standard/CustomerTicketMessage.dtl" to "Custom/Kernel/Output/HTML/Standard/CustomerTicketMessage.dtl"
I didnt get your 4th step. Can you be more specific please? Thanks in advanced.

What should i do if I,
I just want to add customer IP only on ViewZoom page. I dont want to show agent's IP. Is it possible? How ? :shock:

Thanks !
OTRS 4.0.10-02 PostgreSQL 9.3.5
Perl 5.10.1 (linux) is used.
OS: Cent OS 6.5
rtocci62
Znuny newbie
Posts: 15
Joined: 29 Jul 2013, 11:07
Znuny Version: 3.0.10

Re: [SOLVED] Insert customer IP address into ticket?

Post by rtocci62 »

Hi guys, does anyone have any idea how to implement this customization in OTRS 5.0.20 by modifying CustomerTicketMessage.tt?

Thank you
StarDestroyer
Znuny newbie
Posts: 20
Joined: 05 Sep 2013, 22:26
Znuny Version: 5.0.x
Real Name: Jake
Company: Hilite International

Re: [SOLVED] Insert customer IP address into ticket?

Post by StarDestroyer »

I did this quite some time ago... I believe must of my steps above still apply, except the file is now Kernel/Output/HTML/Templates/Standard/CustomerTicketMessage.tt

I just looked and I have the following at the very bottom of CustomerTicketMessage.tt:

Code: Select all

<script type="text/javascript">
document.getElementById("DynamicField_ipaddr").value = "[% Env("REMOTE_ADDR") %]";
</script>
OTRS 5.0.x on CentOS 6 w/MySQL Database
rtocci62
Znuny newbie
Posts: 15
Joined: 29 Jul 2013, 11:07
Znuny Version: 3.0.10

Re: [SOLVED] Insert customer IP address into ticket?

Post by rtocci62 »

Thanks StarDestroyer work,
the difference is how reference session variable
document.getElementById ("DynamicField_ipaddr"). Value = "$Env{" REMOTE_ADDR "}"; (OTRS <= 4)
document.getElementById ("DynamicField_ipaddr"). value = "[%Env (" REMOTE_ADDR ")%]";(OTRS 5)

Bye
Post Reply