There have been a lot of questions about how to add a new field to the ticket and rightly so, the more info a user can provide the better. For our purposes we wanted to add a Company field so we knew exactly who we were dealing with.

We added the field successfully and this thread explains the process. As a favor, can someone help us with adding that new field to the "tickets.inc.php" page?!?! It would be greatly appreciated. We'd like to be able to see Company in that table as a column where you see the ticket id, date, department, priority etc.

To add a new field there are 6 places you have to go to accomplish your goal.

MySQL Database: manually add a field to ost_Ticket

support/include/class.ticket.php

support/include/client/open.inc.php

support/include/client/viewticket.inc.php

include/staff/viewticket.inc.php

include/staff/newticket.inc.php

2.) class.ticket.php

Add your variable here:

class Ticket{

var $id;

var $extid;

var $email;

var $status;

var $created;

var $updated;

var $priority;

and here: like so ($this->newvar=$row;)

if(($res=db_query($sql)) && db_num_rows($res)):

$row=db_fetch_array($res);

$this->id =$row;

$this->extid =$row;

$this->email =$row;

$this->fullname =$row;

and here:

//GET

function getId(){

return $this->id;

}

function getExtId(){

return $this->extid;

}

function getEmail(){

return $this->email;

}

function getNewvar(){

return $this->newvar;

}

and here:

function create($var,&$errors,$origin,$autorespond=true,$alertstaff=true) {

global $cfg,$thisclient,$_FILES;

$id=0;

$fields=array();

$fields = array('type'=>'string', 'required'=>1, 'error'=>'newvar required');

and finally:

$extId=Ticket:();

$sql= 'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.

',ticketID='.db_input($extId).

',dept_id='.db_input($deptId).

',priority_id='.db_input($priorityId).

',email='.db_input($var).

',name='.db_input(Format:($var)).

',newvar='.db_input(Format:($var)).

3.) open.inc.php Copy info from other the other fields, just make sure the new field php scripts are different.

4.) viewticket.inc.php Repeat Step 3

5.) staff/viewticket.inc.php Repeat Step 4

6.) staff/newticket.inc.php Repeat Step 5

10 days later

This is a gold mine right here. Just what I was looking for!!

Frink09,

This is exactly what I am looking for to add a new field for the form. I must say I am having a lot of trouble following step3 and above since I don't know exactly what to add and where in the file is a good place to add it. I broke the pages by adding stuff from step 2. Would you be able to explain what I really need to do in step 3?

Thanks a bunch,

G

My line numbers might be a little off as I have other mods but...

class.ticket.php Step 1: approx line 27

class.ticket.php Step 2: approx line 62

class.ticket.php Step 3: approx line 111

class.ticket.php Step 4: approx line 820

class.ticket.php Step 5: approx line 913

3.) open.inc.php Copy info from other the other fields, just make sure the new field php scripts are different.

Say you were adding a confirm email address field, just copy:

$fields = array('type'=>'email', 'required'=>1, 'error'=>'Valid email required');

Paste, then change it to:

$fields = array('type'=>'confirm_email', 'required'=>1, 'error'=>'Email addresses must match');

I changed the elements so they would have different names.

***NOTE:

the 'type' refers to the type of data on the form. confirm_email is not a default type. Here is a list of the types supported for validation by default.

'integer':

'int':

'double':

'text':

'string':

'array':

'radio':

'date':

'time':

'phone':

'fax':

'email':

'url':

'password':

'username':

'zipcode'

Hope this helps you apply the mod.

Also I have not followed these steps yet, I plan on adding fields later today or tomorrow. I will follow up with success or failure.

micro3d,

Thanks a bunch for this. I will try it out very soon and post my outcome. Thanks again for this.

5 days later

This was the biggest problem we had with osticket, thanks!

Glad to be of help. Sorry I didn't respond sooner, got distracted with other things. With the help of another user we were able to insert our Company Field as a column in the Staff Tickets area.

11 days later

Problema al crear nuevo ticket

Estimados,

Segui las instrucciones paso a paso para poder agregar mas opciones al formulario (field) pero encontre un error.

Al tratar de crear un nuevo ticket sin estar autenticado, funciona bien-

Pero, al tratar de crear un nuevo ticket estando autenticado no se despliega la página completamente.

He buscado en el ćodigo cual puede ser ewl problema y no pude encontrar nada.

Alguine me puede ayudar?

Best regards

Saludos

BAGG

Google Translation

Estimates,

Segui the directions step by step to add more options to form (field) but I found a mistake.

In trying to create a new ticket without being authenticated, works well -

But in trying to create a new ticket not be authenticated unfolds page completely.

He looked at ćodigo which can be EWL problem and I could not find anything.

Alguin can help me?

I think he is saying on the client side it works fine but on the Staff Ticket creation side it is broken.

As for a fix... I'd guess you would need to add your new fields to the staff\newticket.inc.php just the same as you did for client\open.inc.php

Im going to make time right now to do this mod so I can actually come up with some real ideas.

Hi,

status is:

User not autenticated: good creted new ticket, not problem

User autenticated: problem in create new ticket (show page incomplete)

Staff: good, not problem.

best regards.

BAGG

I was able to successfully add a new field to my ticket. I tested it in the client side and the staff side(w/o mod) and it works great!

/* Add New Fields Modification

* Author: James Williams

* osTicket v1.6 RC4

* Date: 07-22-08

* Ref: http://www.osticket.com/forums/showthread.php?t=873(http://www.osticket.com/forums/showthread.php?t=873)

*/

DB Table: ost_ticket

Field Type Collation Attributes Null

location text latin1_general_ci No

+ADD include\client\open.inc.php between subject and intersection

<tr>

<th valign="top">Location, Address, or Intersection:</th>

<td>

<? if($errors) {?> <font class="error"><b>&nbsp;<?=$errors?></b></font><br/><?}?>

<textarea name="location" cols="35" rows="3" wrap="soft" style="width%"><?=$info?></textarea></td>

</tr>

+ADD include\class.ticket.php

var $location; // mod080722_new_ticket_field

+ADD include\class.ticket.php

$this->location =$row; // Mod080722_new_ticket_field

+ADD include\class.ticket.php

// mod080722_new_ticket_field

function getLocation() {

return $this->row;

}

+ADD include\class.ticket.php

$fields = array('type'=>'text', 'required'=>0, 'error'=>'Provide a location, address, or directions'); //mod080722_new_ticket_field

+ADD include\class.ticket.php

//We are ready son...hold on to the rails.

$extId=Ticket:();

$sql= 'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.

',ticketID='.db_input($extId).

',dept_id='.db_input($deptId).

',priority_id='.db_input($priorityId).

',email='.db_input($var).

',name='.db_input(Format:($var)).

',subject='.db_input(Format:($var)).

',location='.db_input(Format:($var)). // mod080722_new_ticket_field

',phone='.db_input($var).

',ip_address='.db_input($ipaddress).

',source='.db_input($source);

Hi,

status is:

User not autenticated: good creted new ticket, not problem

User autenticated: problem in create new ticket (show page incomplete)

Staff: good, not problem.

best regards.

BAGG

I just tested my Mod with an Auth User. Ticket created fine. Is your new field required? Also, could you attach your class.ticket.php and open.inc.php

Por otra parte, ¿podría adjuntar su class.ticket.php y open.inc.php (google)

In your open.inc.php Lines 30 to 41

Empresa:

<?if ($thisclient && ($newvar=$thisclient->getNewvar())) {

?>

"><?=$newvar?>

<?}else {?>

">

<?}?>

 * <?=$errors?>

Delete that temporarily. This will tell us if it is the getNewvar() function that is hold up the page. If it loads fine after this is deleted then the problem is with getting your Newvar out of your database.

Also, $thisclient->getNewvar() isn't calling your getNewvar() function from class.ticket.php , it is calling it from class.client.php.

After the ticket is made the company name is saved with the ticket, that is how you can view your company from the view ticket. When you are on the new ticket page, your name and email are pulled from class.client.php so you might have to create a company var in class.client.php and add a field in your DB and edit the sql on line 45

The attached files are the files that the user sent me for me to look over. I included them for reference if anyone else is having the same problem.

[CompanyField.zip](https://forum.osticket.com/assets/files/migrated/1/75797bf4b231617949d7eaaa7cd8e43.zip)

Can a Wizard be created to add fields?

Hey everyone,

This seems like agreat product.

But like this thread suggests, new fields are needed to be added or others need to be modified.

I am seeking a customizable ticket system for my group at work.

Can a wizard be created to allow the user to customize the ticket form?

Thank you and God bless,

Johnathan

http://www.agodblessedman.com(http://www.agodblessedman.com)

a month later

To add a new field there are 6 places you have to go to accomplish your goal.

MySQL Database: manually add a field to ost_Ticket

Would anyone mind explaining the steps to add a field to a database?

13 days later

This was a big help. Thanks

Does anyone have the code to add drop down menus to the new field? I simply want to add a few choices to that field. Thanks so much for the coding to add a new category. It worked like a charm.

25 days later

exactly what i wanted but.

Ok this is exactly what I was looking for, the ability to make custom fields on the tickets. I have spent about 4 hours of my free time and about another 4 hours at work trying to get this modification to function properly.

I needed to add to the ticket form the field of Serial Number, I added it using the tutorial in this thread but when both the phone field and the Serial number fields are entered, the phone field appears then vanishes when you view a ticket, it does the same thing when i view the table in MySQL. Why is this? I have spent quite a bit of time moving the fields around and dropping them and putting them back up. I have also re-written all of the modifications in the php files quite a few times, and played around with the options in MySQL. What am i missing? anyone have any ideas where i should look to correct this problem?

Ok this is exactly what I was looking for, the ability to make custom fields on the tickets. I have spent about 4 hours of my free time and about another 4 hours at work trying to get this modification to function properly.

I needed to add to the ticket form the field of Serial Number, I added it using the tutorial in this thread but when both the phone field and the Serial number fields are entered, the phone field appears then vanishes when you view a ticket, it does the same thing when i view the table in MySQL. Why is this? I have spent quite a bit of time moving the fields around and dropping them and putting them back up. I have also re-written all of the modifications in the php files quite a few times, and played around with the options in MySQL. What am i missing? anyone have any ideas where i should look to correct this problem?

I have to step out of the office atm but I will address this issue and work with you to try and get you up and going today.

Im back

Can you post or email me your files? use the list at the start of the thread for which files I need.

micro3d gmail com

I will give them a review and try to get back to you asap.