Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Adding a New Field to tickets

1234568

Comments

  • Has anyone recently installed this and find that the method in OP still works properly? I am looking to add a Price field, but don't want to get started on something that may not work.
  • I followed the below instructions but got the following database error:

    [INSERT INTO ost_ticket SET created=NOW() ,ticketID=643269,dept_id=1,topic_id=1,priority_id=2,email='emmanuel1hall@gmail.com',name='Emmanuel Hall',subject='testing again',valid_id=109449452,helptopic='Support',phone="8767747777",phone_ext='',ip_address='72.27.38.117',source='Web']

    Unknown column 'valid_id' in 'field list'

    What must I do to correct this?
    Frink09;3304 said:
    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.
    [LIST=1]
    [*]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
    [/LIST]

    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['newvar'];)


    if(($res=db_query($sql)) && db_num_rows($res)):
    $row=db_fetch_array($res);
    $this->id =$row['ticket_id'];
    $this->extid =$row['ticketID'];
    $this->email =$row['email'];
    $this->fullname =$row['name'];

    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['newvar'] = array('type'=>'string', 'required'=>1, 'error'=>'newvar required');


    and finally:


    $extId=Ticket::genExtRandID();
    $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['email']).
    ',name='.db_input(Format::striptags($var['name'])).
    ',newvar='.db_input(Format::striptags($var['newvar'])).


    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


    4.) staff/newticket.inc.php Repeat Step 5
  • Did you carry out step 1 of the instructions (manually adding the field to your MySQL database)?
  • Unknown column 'Support Agreement Ref:' in 'field list'

    Hi all, im new to the board, Ive just installed an instance of OS tickets to my site and I've added 2 extra fields and removed the "phone ext" field. I'm getting the same fault on one entry, above. I've logged in to my php admin and added extra fields to the DB.

    I've changed the php to each entry to give it a unique name, when I run a query in my SQL it gives me the sane error as Emmanuel.

    Do we think that field lists should be quotated not apostrophe ?
  • [INSERT INTO ost_ticket SET created=NOW() ,ticketID=734362,dept_id=1,topic_id=1,priority_id=2,email='stuart.peck@virgin.net',name='Stuart Peck',company='',Support_Agreement_No=11111,subject='Tech help needed',helptopic='2. Technical Support',phone="07713813251",ip_address='91.125.154.106',source='Web']




    Full error above. Does the name need to be exactly the same throughout the code in order for it to work?
  • Anyone have any idea?
  • Scroll down

    Hi.

    Who can tell me step by step how to make a scroll down box like help topic?
  • confused

    :confused:

    which steps i have to follow to create a "New Filed" in users new ticket screen and also the same has to get update in staff screen..

    pl suggest
  • Take it even further

    This is a great post and I have already been able to add two fields, but having a trouble with a third. However, that's not what I am posting about.

    Could someone explain what each line of code is for? I am fairly new to PHP, having all of a week and a half of experience, and I have learned a lot, but am really looking to learn more.

    Part of why I am asking is I am looking to accomplish something that could benefit from this knowledge. I have created a field called "store", which is a drop down that pulls from a table. I would like to Remove the subject field from displaying on newticket.inc.php, but I still want to record this field to the database. What I want recorded in the subject field is this: [help_topic] - [store]. So it might look something like "Billing - Branch 153".

    I am just unsure of where in the function it actually writes to the database. I will play around with and see what happens, but am hoping someone can help me with. I can provide my files if necessary.

    TIA for any help that can be provided.
  • Hi all
    I need a little help in here.
    I have made a new field, contain company numbers no problem in that, but after 2 years now, I rely need to search for these numbers?
    What do I need to do so I can search in that field or better all field and massage?
    Cheers
    Jimmy
  • See lines 133-150 in includes/staff/tickets.inc.php
  • I have the same problem. I created a new field call "MemberId" and I everything displays correctly but I can't search by that field.

    I added this to tickets.inc.php line 130-150

    //This sucks..mass scan! search anything that moves! 

    $deep_search=true;
    if($_REQUEST['stype'] && $_REQUEST['stype']=='FT') { //Using full text on big fields.
    $qwhere.=\" AND ( ticket.email LIKE '%$queryterm%'\".
    \" OR ticket.MemberId LIKE '%$queryterm%'\". <--Added this line for my field
    \" OR ticket.name LIKE '%$queryterm%'\".
    \" OR ticket.subject LIKE '%$queryterm%'\".
    \" OR note.title LIKE '%$queryterm%'\".
    \" OR MATCH(message.message) AGAINST('$queryterm')\".
    \" OR MATCH(response.response) AGAINST('$queryterm')\".
    \" OR MATCH(note.note) AGAINST('$queryterm')\".
    ' ) ';
    }else{
    $qwhere.=\" AND ( ticket.email LIKE '%$queryterm%'\".
    \" OR ticket.name LIKE '%$queryterm%'\".
    \" OR ticket.subject LIKE '%$queryterm%'\".
    \" OR message.message LIKE '%$queryterm%'\".
    \" OR response.response LIKE '%$queryterm%'\".
    \" OR note.note LIKE '%$queryterm%'\".
    \" OR note.title LIKE '%$queryterm%'\".
    ' ) ';
  • This works for me when memberID is part of the ost_ticket table.

    open include/class.ticket.php

    on line 46 add

    var $memberID;


    find this code (should be around line 92)...

    $this->row=$row;


    and directly above that, insert this line...

    $this->memberID =$row['memberID'];


    Your search code in tickets.inc.php should now work properly.

    :cool:
  • Hey teryakisan thanks for the reply.

    I checked class.tickets.php and I already have those rows.
    I'm pretty new to php and sql both. Could it have to with that I have memberid written out as 'MemberId'?
    I consistently wrote it that way but that is the only difference I see with how I added everything.
  • make sure you have MemberID referenced in BOTH instances of $qwhere.


    $deep_search=true; 
    if($_REQUEST['stype'] && $_REQUEST['stype']=='FT') { //Using full text on big fields.
    $qwhere.=\" AND ( ticket.email LIKE '%$queryterm%'\".
    \" OR ticket.MemberId LIKE '%$queryterm%'\". <--Added this line for my field
    \" OR ticket.name LIKE '%$queryterm%'\".
    \" OR ticket.subject LIKE '%$queryterm%'\".
    \" OR ticket.subject LIKE '%$queryterm%'\".
    \" OR note.title LIKE '%$queryterm%'\".
    \" OR MATCH(message.message) AGAINST('$queryterm')\".
    \" OR MATCH(response.response) AGAINST('$queryterm')\".
    \" OR MATCH(note.note) AGAINST('$queryterm')\".
    ' ) ';
    }else{
    $qwhere.=\" AND ( ticket.email LIKE '%$queryterm%'\".
    \" OR ticket.MemberId LIKE '%$queryterm%'\". [COLOR=\"Red\"]<--- ADD IN THIS LINE[/COLOR]
    \" OR ticket.name LIKE '%$queryterm%'\".
    \" OR ticket.subject LIKE '%$queryterm%'\".
    \" OR message.message LIKE '%$queryterm%'\".
    \" OR response.response LIKE '%$queryterm%'\".
    \" OR note.note LIKE '%$queryterm%'\".
    \" OR note.title LIKE '%$queryterm%'\".
    ' ) ';
  • That was it!
    I didn't have it listed in the second instance of $qwhere

    Thanks a lot teryakisan!
  • Excellent. Glad to help. :cool:
  • Select List?

    Hello, thank you in advance.

    I need to add a field named, conveniently enough, location. However, I need a select box, and I am not sure how or where to put the <?=$info['location']?> in /include/client/open.inc.php

    Here is an idea of what I am after:

    <tr>
    <th valign=\"top\">Location:</th>
    <td>
    <? if($errors['location']) {?> <font class=\"error\"><b>&nbsp;<?=$errors['location']?></b></font><br/><?}?>
    <select name=\"location\" >
    <option value=\"Boise HQ\">Boise HQ</option>
    <option value=\"Emmett\">Emmett</option>
    <option value=\"Nampa\">Nampa</option>
    <option value=\"Payette\">Payette</option>
    <option value=\"Program Coordination\">Program Coordination</option>
    <option value=\"Rupert\">Rupert</option>
    <option value=\"Sandcastles\">Sandcastles</option>
    <option value=\"Twin Falls\">Twin Falls</option>
    <option value=\"Weiser\">Weiser</option>
    <option value=\"Other\">Other</option>
    </select>
    </td>
    </tr>
  • Added new field sucessfully but problem at the time of create ticket by Email

    Hi,

    I added one new field at newticket.php and make changes in other files too.
    when i create ticket with user login it woks fine. But when i send an email ticket will not create.
    please tell mi what change should i do in Mailfetch.php file.So i cann create ticket via email also.

    thanks an adv.
  • T313C0mun1s7;27924 said:
    Hello, thank you in advance.

    I need to add a field named, conveniently enough, location. However, I need a select box, and I am not sure how or where to put the <?=$info['location']?> in /include/client/open.inc.php

    Here is an idea of what I am after:

    <tr>
    <th valign=\"top\">Location:</th>
    <td>
    <? if($errors['location']) {?> <font class=\"error\"><b>&nbsp;<?=$errors['location']?></b></font><br/><?}?>
    <select name=\"location\" >
    <option value=\"Boise HQ\">Boise HQ</option>
    <option value=\"Emmett\">Emmett</option>
    <option value=\"Nampa\">Nampa</option>
    <option value=\"Payette\">Payette</option>
    <option value=\"Program Coordination\">Program Coordination</option>
    <option value=\"Rupert\">Rupert</option>
    <option value=\"Sandcastles\">Sandcastles</option>
    <option value=\"Twin Falls\">Twin Falls</option>
    <option value=\"Weiser\">Weiser</option>
    <option value=\"Other\">Other</option>
    </select>
    </td>
    </tr>
    the option value should look like this (based on your last entry there. Replace Other with the option in each case):

    <option value=\"Other\" <?=($info['location']=='Other')?'selected':''?>>Other</option>


    or at least that works for me in newticket.inc.php I am not using the client side entry of the program
  • jsaulnier;27936 said:
    the option value should look like this (based on your last entry there. Replace Other with the option in each case):

    <option value=\"Other\" <?=($info['location']=='Other')?'selected':''?>>Other</option>


    or at least that works for me in newticket.inc.php I am not using the client side entry of the program
    Thank you for your fast response, I will try this. It is probably a moot point as I will be creating my own form anyhow for WordPress integration as per (http://cloudpointoh.com/better-os-ticket-wordpress-integration/), but I wanted to use the generated form as a skeleton and confirm everything is functioning as it should with osTicket first.

    EDIT: One quick question (I don't know PHP) does it become
    >Other
    for the unselected options? So the entire thing would be

    [HTML]

    Location:

    <? if($errors['location']) {?>  <?=$errors['location']?>
    <?}?>

    >Boise HQ
    >Emmett
    >Nampa
    >Payette
    >Program Coordination
    >Rupert
    >Sandcastles
    >Twin Falls
    >Weiser
    >Other



    [/HTML]
  • T313C0mun1s7;27940 said:
    Thank you for your fast response, I will try this. It is probably a moot point as I will be creating my own form anyhow for WordPress integration as per (http://cloudpointoh.com/better-os-ticket-wordpress-integration/), but I wanted to use the generated form as a skeleton and confirm everything is functioning as it should with osTicket first.

    EDIT: One quick question (I don't know PHP) does it become
    >Other
    for the unselected options? So the entire thing would be

    [HTML]

    Location:

    <? if($errors['location']) {?>  <?=$errors['location']?>
    <?}?>

    >Boise HQ
    >Emmett
    >Nampa
    >Payette
    >Program Coordination
    >Rupert
    >Sandcastles
    >Twin Falls
    >Weiser
    >Other



    [/HTML]
    That looks about right to me. But I am fairly new to PHP myself...
  • jsaulnier;27942 said:
    That looks about right to me. But I am fairly new to PHP myself...
    Thanks again. I don't have the staff side fully finished yet, but from what I can see in phpMyAdmin it looks to be working correctly.

    Maybe someone can use this example in the future and it will help them too.
  • Now I am running into an issue.

    I have a field that I put in that contains the first 5-digits of an internal account number. The issue is that sometimes the first digit is a zero.

    Even though I set the type for the field to text in class.ticket.php, and the field in the MySQL table is set to Text, it still strips that leading 0.

    Any thoughts?
  • Thanks so much for the help so far. I am close to getting this to work. The only problem now is that when I add


    Users Name:
    <?=Format::htmlchars($ticket->getUsers_Name())?>


    to viewticket.inc.php

    ....everything AFTER that point won't display on the page. I added it after the getName variable and even tried it after other variables and it won't display the value requested nor anything after. I get a blank page after that point.

    Any Pointers?
  • Adding to viewticket.inc.php

    I can add some things like Source and Subject, but even when i try VARs that have been standard to OSTicket they do the same.

    <?=Format::htmlchars($ticket->getip_address())?>

    And even if i try my new VARs

    <?=Format::htmlchars($ticket->getusers_name())?>
    <?=Format::htmlchars($ticket->getusers_email())?>

    I still end up with the viewticket.inc.php, cutting off the rest of the form forward from the point of insertion of any of the above lines.

    Please please help...

    Thanks
  • Doesnt matter resolved it, i was using the wrong get name as some are different to the row names.
  • Getting the new field on the forms but no entry into the database

    Hey everyone, this thread has been great but I'm an issue getting entry's into the database. The field shows up fine on the forms, just nothing gets entered into the database. I believe I have it setup correct on the database side. I've attached a zip file containing my php files. Can someone check them over to see where I'm messing up? The field i'm creating is Property Tag, and the variable is prop. The property tag column on the database is:

    Column Name: propertytag
    Datatype: varchar(45) this might need to be change? Our Tag numbers are 6 numbers.
    The options I have: Not Null checked, should this be changed? I don't have anything else selected.

    Thanks for the help everyone!
    osticket.zip
    37K
  • Help?
    Gonzo1982;27974 said:
    Hey everyone, this thread has been great but I'm an issue getting entry's into the database. The field shows up fine on the forms, just nothing gets entered into the database. I believe I have it setup correct on the database side. I've attached a zip file containing my php files. Can someone check them over to see where I'm messing up? The field i'm creating is Property Tag, and the variable is prop. The property tag column on the database is:

    Column Name: propertytag
    Datatype: varchar(45) this might need to be change? Our Tag numbers are 6 numbers.
    The options I have: Not Null checked, should this be changed? I don't have anything else selected.

    Thanks for the help everyone!
    Can anyone help with this above? I would really appreciate it. I think its just a small thing I'm missing in the code.

    Thanks
  • Adding extra fields to ticket is showing like required (type not set)

    Adding extra fields to ticket is showing like required (type not set),even i created database fields and validations.
    my fields are Customer Name.Customer Location.
    database fields are
    cname varchar(32) NOT NULL default '',
    clocation varchar(32) NOT NULL default '',
    link is
    http://support.exleaz.co.uk/CustomerSupport/open.php
Sign In or Register to comment.