I need to add 4 text fields to 'Add Service' similar to Comment: field.

Moderator: crythias

Locked
zbigniew
Znuny newbie
Posts: 53
Joined: 11 Dec 2014, 13:30
Znuny Version: 5.0.23
Real Name: Zbigniew Luszpinski

I need to add 4 text fields to 'Add Service' similar to Comment: field.

Post by zbigniew »

OTRS 4.0.2 Admin->Services->Add service:
I need to add 4 text fields to 'Add Service' similar to Comment: field.

To make this possible:
- added 4 new varchar(250) columns to otrs database->service table in MySQL;
- added text fields to AdminService.tt file so they are visible in web browser.
<div class="Clear"></div>
<label for="my_field">my new field: </label>
<div class="Field">
<input type="text" name="my_field" id="my_field" value="[% Data.my_field | html %]" class="W50pc" maxlength="250"/>
</div>
<div class="Clear"></div>

- added fields to AdminService.pm
for (qw(ServiceID ParentID Name ValidID Comment TypeID Criticality my_field)) {

And this does not work. Fields appeared on page but when I fill them and click Save changes are not saved. If I put manually data to database they are not read to web form.
What is missing?
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: I need to add 4 text fields to 'Add Service' similar to Comment: field.

Post by jojo »

you should not change the code without any knowledge of the OTRS Layout and design.

You can register preferences for the service.

You can just add the following code (4 times in your case) to the Config.pm

Code: Select all

$Self->{'ServicePreferences'}->{'Comment2'} =  {
  'Block' => 'TextArea',
  'Cols' => '50',
  'Desc' => 'Define the service comment 2.',
  'Label' => 'Comment2',
  'Module' => 'Kernel::Output::HTML::ServicePreferencesGeneric',
  'PrefKey' => 'Comment2',
  'Rows' => '5'
};
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
zbigniew
Znuny newbie
Posts: 53
Joined: 11 Dec 2014, 13:30
Znuny Version: 5.0.23
Real Name: Zbigniew Luszpinski

Re: I need to add 4 text fields to 'Add Service' similar to Comment: field.

Post by zbigniew »

Thanks @jojo for help. How to remove: 'Desc' => 'Define the service comment 2.' ,?
'Desc' => 'Define the service comment 2.', shows text: (Define the service comment 2.) under text input field.
When removed this line I see empty () under text field.
When done: 'Desc' => 0, text: (0) was displayed.
How to stop displaying 'Desc' because do not need this?

Anyway thanks for help - works great. Here is improved version I made:
+Replaces Text box with single input line which looks better.

Code: Select all

$Self->{'ServicePreferences'}->{'Comment2'} =  {
  'Block' => 'Input',
  'Desc' => 'Define the service comment 2.',
  'Label' => 'Comment2',
  'Module' => 'Kernel::Output::HTML::ServicePreferencesGeneric',
  'PrefKey' => 'Comment2',
};
Locked