Pass CGI environment variables IP hostname to TicketFreeText

Dont create your support topics here! No new topics with questions allowed!

Moderator: crythias

gears
OTRS newbie
Posts: 37
Joined: 24 Feb 2011, 18:29
OTRS Version?: 5.0.14

Pass CGI environment variables IP hostname to TicketFreeText

Postby gears » 03 Apr 2011, 07:43

Credit for this howto goes to Crythias. He answered my questions with the basics here: http://forums.otrs.org/viewtopic.php?f=61&t=8933.
Consider this just an expanded writeup for future reference. The goal I was going for was to create custom links in the AgentTicketZoom which display the customer's IP and hostname and url's containing these variables for agents to pull up pages on an external server.
:)

Review the CGI Environment variables enumerated here: http://www.cgi101.com/book/ch3/text.html
Take note of the following since they would be the most useful for this purpose:

-REMOTE_ADDR The IP address of the visitor
-REMOTE_HOST The hostname of the visitor
-REMOTE_USER The visitor's username


edit /Kernel/Output/HTML/Standard/CustomerTicketMessage.dtl and add the following somewhere near the end:

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"}";
      document.getElementById('TicketFreeText2').style.display = 'none';
      document.getElementById('LabelTicketFreeText2').style.display = 'none';
      document.getElementById('TicketFreeText2').value = "$Env{"REMOTE_HOST"}";
</script>



Add the following to /etc/apache2/conf.d/otrs.conf only if you need/want hostname lookups and also understand that this may cause a performance degradation if dns lookups are not extremely fast on your network.

Code: Select all

hostnameLookups On

Restart your apache server however your distro typically handles this.


Sysconfig:
note: What follows assumes that you currently have a default configuration with all TicketFreeKey* and TicketFreeText* turned off in sysconfig.
Edit Config Settings in Ticket -> Core::TicketFreeText
-Enable TicketFreeKey1
-Enter "IP Address" or something equally descriptive for the Key and erase the content to make it blank
-For my purposes I chose to also enable TicketFreeText1::Link but this is optional
-For the URL: "http://externalservername/default.aspx?item=quicksearch&q=$LQData{"TicketFreeText1"}" which links the IP address shown in the interface to pages on our external inventory server.
-Enable TicketFreeKey2
-Enter "Hostname" or something equally descriptive for the Key and erase the content to make it blank
-For my purposes I chose to also enable TicketFreeText2::Link but this is optional
-For the URL: "http://externalservername/default.aspx?item=quicksearch&q=$LQData{"TicketFreeText2"}" which links the hostname shown in the interface to pages on our external inventory server.
-Update

Edit Config Settings in Ticket -> Frontend::Customer::Ticket::ViewNew
-In Ticket::Frontend::CustomerTicketMessage###TicketFreeText for Key "1" and Key "2" change the Content "0" to "1"
-Update

Edit Config Settings in Ticket -> Frontend::Agent::Ticket::ViewFreeText
-In Ticket::Frontend::AgentTicketFreeText###TicketFreeText for Key "1" and Key "2" change the Content "0" to "1"
-Update

Now for newly created tickets, you should see something like the following in AgentTicketZoom!



Troubleshooting tip:
View the source from the customer interface CustomerTicketMessage (New Ticket Creation) to find out if the variables are being correctly set. Divide and eliminate problems from there.
You do not have the required permissions to view the files attached to this post.
Last edited by gears on 03 Dec 2016, 02:15, edited 1 time in total.
OTRS 5.0.14 / Debian 7.11 x64 / Apache 2.2.22 / MySQL 14.14 Distrib 5.5.53

blindbaby
OTRS newbie
Posts: 1
Joined: 10 Oct 2011, 11:20
OTRS Version?: 3.0.4
Real Name: kira
Company: Profitex

Re: Pass CGI environment variables IP hostname to TicketFree

Postby blindbaby » 10 Oct 2011, 11:24

Thanks for the detailed report!!! I found here lots of good stuff that I needed before. That really helped me to solve my challenge!!!

Romaing
OTRS expert
Posts: 60
Joined: 30 Mar 2012, 15:20
OTRS Version?: 3.1.5

Re: Pass CGI environment variables IP hostname to TicketFree

Postby Romaing » 09 May 2012, 16:25

Hello,

On OTRS 3.1, do you have an idea of what changes need to be made ?

I'm looking to do the same thing: display the customer IP as well as his hostname just like your pic showed.

If i add those lines of javascript in the CustomerTicketMessage.dtl file, then i get js errors at the page display. By "somewhere near the end" i'm guessing in there:

Code: Select all

<script type="text/javascript">
    Core.Customer.InitFocus();
</script>


But more importantly, the Core::TicketFreeText is deemed as deprecated now in OTRS 3.1, and the settings :
Ticket::Frontend::CustomerTicketMessage###TicketFreeText
Ticket::Frontend::AgentTicketFreeText###TicketFree

do not exist anymore :?
OTRS 3.1.5 on Ubuntu 12.04
Database: MySQL
Module: FAQ

yuri0001
OTRS ninja
Posts: 631
Joined: 17 Mar 2011, 14:40
OTRS Version?: 5.0.6
Real Name: Yuri Kolesnikov
Location: Russia

Re: Pass CGI environment variables IP hostname to TicketFree

Postby yuri0001 » 10 May 2012, 15:01

In 3.1.x all FreeText fields are replaced with New feature - Dynamic Fields - see admin manual for 3.1
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)

yuri0001
OTRS ninja
Posts: 631
Joined: 17 Mar 2011, 14:40
OTRS Version?: 5.0.6
Real Name: Yuri Kolesnikov
Location: Russia

Re: Pass CGI environment variables IP hostname to TicketFree

Postby yuri0001 » 23 May 2012, 12:23

One more question, please. :?
Is this method works when customer logged in OTRS through proxy-server? Is displayed IP-address of customer where right?
Or it be Proxy - address? If that - how to workaround it?
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)

micshi
OTRS wizard
Posts: 191
Joined: 05 Jul 2011, 16:10
OTRS Version?: 3.2.2
Real Name: Micshi
Location: Beijing
Contact:

Re: Pass CGI environment variables IP hostname to TicketFree

Postby micshi » 29 May 2012, 10:07

No, In proxy environment the IP address got from CGI is the IP address of Proxy Server.

micshi
OTRS 3.2.2, ITSM 3.2.2, SystemMonitor
Ubuntu, Apache2, MySQL 5
My OTRS Blog
OTRS Basic Concept Training
OTRS Demo Instance


Return to “Howtos”

Who is online

Users browsing this forum: No registered users and 2 guests