Pass CGI environment variables IP hostname to TicketFreeText

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

Moderator: crythias

Forum rules
Dont create your support topics here! No new topics with questions allowed!
Post Reply
gears
Znuny newbie
Posts: 38
Joined: 24 Feb 2011, 18:29
Znuny Version: 5.0.14

Pass CGI environment variables IP hostname to TicketFreeText

Post by gears »

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? ... tFreeText1"}" 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? ... tFreeText2"}" 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
Znuny newbie
Posts: 1
Joined: 10 Oct 2011, 11:20
Znuny Version: 3.0.4
Real Name: kira
Company: Profitex

Re: Pass CGI environment variables IP hostname to TicketFree

Post by blindbaby »

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
Znuny newbie
Posts: 60
Joined: 30 Mar 2012, 15:20
Znuny Version: 3.1.5

Re: Pass CGI environment variables IP hostname to TicketFree

Post by Romaing »

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
Znuny superhero
Posts: 631
Joined: 17 Mar 2011, 14:40
Znuny Version: 5.0.6
Real Name: Yuri Kolesnikov
Location: Russia

Re: Pass CGI environment variables IP hostname to TicketFree

Post by yuri0001 »

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
Znuny superhero
Posts: 631
Joined: 17 Mar 2011, 14:40
Znuny Version: 5.0.6
Real Name: Yuri Kolesnikov
Location: Russia

Re: Pass CGI environment variables IP hostname to TicketFree

Post by yuri0001 »

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
Znuny expert
Posts: 191
Joined: 05 Jul 2011, 16:10
Znuny Version: 3.2.2
Real Name: Micshi
Location: Beijing
Contact:

Re: Pass CGI environment variables IP hostname to TicketFree

Post by micshi »

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
Post Reply