Monday, June 28, 2010

Tracking Customer Companies in OTRS.

I have been playing abound with OTRS for the past few days and ran into a bit of a snag.  I installed it from the Ubuntu repositories but noticed that the Customers can't be linked to the Companies witch would be a useful feature.  I also found out after some digging that there was no option in the SysConfig to fix this.  I found the setting by manually editing the config files but this was of limited use.  In the end I had to make a few manual edits to make the system work as expected.  I outlined the changes below to the base 2.4.7 install.

First open a terminal and cd to your otrs install directory.
cd /usr/share/otrs

Enable CustomerCompanySupport
sudo vim Kernel/Config.pm
Add the following line inside the sub Load method.
# Enable Customer Company linking.
$Self->{CustomerUser}->{CustomerCompanySupport} = 1;

Run the mysql client and add a field to the customer table.
mysql -u root -p
use otrs2;
alter table customer_user add column company_id varchar(100);
exit

Register the extra row with the editor.
sudo vim Kernel/Config/Defaults.pm
Find the CustomerUser variable and then the Map array within it.  Add the following line after the UserCustomerID field.
[ 'UserCompanyID',  'CompanyID',  'company_id',  0, 1, 'var', '', 0 ],

Change the company dropdown list to trigger on the new CompanyID field.
sudo vim Kernel/Modules/AdminCustomerUser.pm
Look for the reference to UserCustomerID and change it to UseCompanyID. It should look like this now.
$Entry->[0] =~ /^UserCompanyID$/i

Change the dispaly logic to match against the new CompanyID.
sudo vim Kernel/System/CustomerUser.pm
Look for the reference to UserCustomerID and change it to UseCompanyID. It should look like this now.
CustomerID => $Customer{UserCompanyID},

You can now restart apache and the changes should show up.
sudo /etc/init.d/apache2 restart

5 comments:

Egor said...

Hi, I've tried your customization but I still can't see the difference. Maybe I just can't find the difference. I'm still have no link between CustomerUser and CustomerCompany. Can u explain what this customization do?

Jeremy Pyne said...

Specificly what his changes is: on my fresh instLl of orts there was no field on the users table to indicate witch company the user belongs to. These changes add a new field to track this assoscian and adds he field to the edit screen. It does not however add the logic to generate reports or do searches by this new field.

Egor said...

Jeremy, do you now is it possible to add drop down list in Customer User edit interface where you can choose Customer Company created in the Customer Company edit interface?

Diego said...

this was fixed in otrs3?

Jeremy Pyne said...

In Otrs3 you can use the 'CustomerID' field to track the company/department. When set it will let users with the same CustomerID see each others requests search and report by CustomerID