[Solved]Hardcode freetextfield

Moderator: crythias

Locked
adt
Znuny newbie
Posts: 43
Joined: 28 Jun 2012, 17:04
Znuny Version: 2.4.9

[Solved]Hardcode freetextfield

Post by adt »

Hi,
is it possible to hardcode a freetext such that it's not shown up on Customer forntend screen, but on creation of ticket its value is stored in database.

EX : I mean i want to hardcode freetextfield16 for tickets such that it always stores the same value say "1 million" but Customer can set it in frontend.
Last edited by adt on 27 Jul 2012, 15:01, edited 1 time in total.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Hardcode freetextfield

Post by crythias »

Render the field on a browser to get the name= parameter of the input field, then make an
<input type="hidden" name="fieldname" value="CustomerCan'tChangeThisValue">
in the form.
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
adt
Znuny newbie
Posts: 43
Joined: 28 Jun 2012, 17:04
Znuny Version: 2.4.9

Re: Hardcode freetextfield

Post by adt »

hi crythias ,

i am talking about this design code in template file so that it shouldn't be shown to the customer and its hardcoded value should be saved to the database.(i want to hardcode a value for TicketFreeTextField16 )

Code: Select all

<tr>
  <td class="hide">$Data{"TicketFreeKeyField16"}:</td>
  <td class="hide">$Data{"TicketFreeTextField16"}</td>
<tr>
i declared hide class for css(inline) in top of the code
.hide
{
visibility:hidden
}
So its hidden in Customer view

In my Config Options: Ticket -> Core::TicketFreeText i have 10 entries for TicketFreeText16:
for ex: say 1,2,22,33,34,53,763 so forth..

now, I just want TicketFreeTextField16 to store automatically one value of these
for ex:say 23

Is that possible?? However, i just don't wanna use the option of default value because it'll affect the other template files also.(i mean TicketFreeText16::DefaultSelection: )

OR
please guide me if i can store some of this value using a perl module(is any perl modules in Kernel responsible for that.)
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Hardcode freetextfield

Post by crythias »

adt wrote:i am talking about this design code in template file so that it shouldn't be shown to the customer and its hardcoded value should be saved to the database.
Me, too.

Code: Select all

<tr>
  <td class="hide">$Data{"TicketFreeKeyField16"}:</td>
  <td class="hide">$Data{"TicketFreeTextField16"}</td>
<tr>
This doesn't do anything except to put the value as a string on a web page but not show it, assuming class="hide" includes display:none. It won't store it in a database.

You need to do exactly what I said: Render the field in a browser, view source to get the name, create an input type=hidden on the .dtl, hide the field.
Although, there are several problems. Customers can't edit text fields after submit. If you don't want them to edit or choose a value for them, ever, don't bother using that field for them. There's no point in assigning a hidden value to a field if the same value applies to all customer submissions because you can easily know that it's a customer web submit after the fact. If the value changes based upon a queue, but it's a one-to-one ratio, why bother storing the value twice?

In general, if you're storing a hidden value based upon something the customer is already going to tell you, there's really no purpose in storing an extra value.

If you *MUST* store a value that varies but there's no way that the customer would be able to choose this value, or you can't determine what the value could be based upon every other field a customer could fill out, you *still* need to put it as an input type="hidden" or if you want to assign it with perl, look at the api http://dev.otrs.org/3.0/Kernel/System/Ticket.html

Code: Select all

TicketFreeTextSet()
Set ticket free text.
    my $Success = $TicketObject->TicketFreeTextSet(
        Counter  => 1,
        Key      => 'Planet', # optional
        Value    => 'Sun',  # optional
        TicketID => 123,
        UserID   => 23,
    );
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
adt
Znuny newbie
Posts: 43
Joined: 28 Jun 2012, 17:04
Znuny Version: 2.4.9

[Solved]Re: Hardcode freetextfield

Post by adt »

i've found out the solution to my problem through perl module for Customer Ticket .

Thank you so much crythias!
Locked