osTicket Version: v1.11.0-rc1
(Note: there is no primary tag yet in this forum for this version so I was forced to pick 1.10)
MySQL Version: 8.0.12
PHP Version: 5.6.31
Server OS: Windows 10 Pro

I have added custom fields to the "Open a New Ticket" form by editing ticket-open.inc.php.
(I am assuming this was the correct file to modify; if not, please let me know.)

Now I wish to populate them from the database. These fields are display only, no update capabilities are required here. The data is in table ost_organization__cdata and was added there by adding fields to the existing "Organization Information" form using Custom Forms from the Admin Panel.

What is the easiest way to extract and display the data? I am new to PHP and have not been able to find enough up-to-date information here in the forums or on the web to piece together a solution. Any help would be appreciated?

If you want to add custom fields then you do not need to edit any files. You would go to Admin panel -> Manage -> Forms -> Ticket Details and add your fields there.

You can also make custom forms and tie them to Help Topics so they only show up if certain help topics are selected. Such as if you had one that was "Printer install". It would ask for the make/model of the printer.

Thanks for the quick response.
I have already tried that. It puts the new fields on the Ticket Details page very nicely, however I would like to have them show up on the Open a New Ticket form instead. There is no built-in form for Open a New Ticket on the Custom Forms page. Plus the data already exists: I am not requesting it, only displaying it.
I did use Custom Forms to add the fields to the Organization Information form and that's where the data is inputted by our agents. That part works great. Now I simply want to display that data back when opening a new ticket. This data would be pulled from where my customized Organization Information form put it and would be joined on the organization the user belongs to.
I also explored the Help Topics approach, but that doesn't display data, it asks for new data, and is also not showing in the optimal location on the page (see my screenshot).
Am I missing something? Is there some way to do this using Custom Forms and I just can't see it?
I've looked at your article "Adding custom text fields to tickets in osTicket 1.7ST" and a few other resources but can't figure out how to transpose that to what I'm trying to do.

I just noticed that if one calls up the user's info from within the ticket it gives you an "Organization" tab with all my custom fields on it and correctly populated. If I could somehow use the dynamic form capabilities to simply drop this dynamic form into the correct location on the "Open a New Ticket" form it would solve everything in one fell swoop, but I don't know how to do that either. Could anyone point me in the right direction?

I dont think that you can do this with out modifying the core files.

Is ticket-open.inc.php considered one of the core files? I'm pretty certain that's the one I need to modify. I found this bit of code in user.tmpl.php:

<?php foreach ($org->getDynamicData() as $entry) {
?>
<tr><th colspan="2"><strong><?php
echo $entry->getTitle(); ?></strong></td></tr>
<?php foreach ($entry->getAnswers() as $a) { ?>
<tr><td style="width:30%"><?php echo Format::htmlchars($a->getField()->get('label'));
?>:</td>
<td><?php echo $a->display(); ?></td>
</tr>
<?php }
}
?>

I think if I paste that into ticket-open.inc.php it will achieve the desired effect, I'm just having difficulties ensuring all the variables used in this code snippet contain what they need to to produce the same output the code produces in its original location. Just pasting it in as-is breaks the page (blanks it) from that point down so I'm assuming that php code is failing because it's not getting what it needs.

Any file included in the download archive is a core file.

That's what I had assumed, thanks for confirming.
I am assuming that the getDynamicData() function gets called from class.organization and not from class.user because I'm assuming that $org is of class type Organization, but that's as far as I've been able to get. Any pointers on how to wrap my head around these data structures and how they are used here? Any debugging suggestions for looking under the hood and tracking the contents of variables?
It would be nice if someone had documented this somewhere. As I mentioned in my first post I am new to PHP. I've never studied it or worked with it before so any help would be appreciated. Thanks.

Sorry I'm not a dev, and have never edited that screen. Maybe someone else here has.

\include\staff\ticket-open.inc.php seems to be correct.
If I make any changes in core files, I try use INCLUDE, if is it possible.
In your case, you can include your own files with SQL queries to read any values from ost_organization__cdata and display it in a labels.

    PavelH That sounds like a good approach. I'll see if it helps me. Thanks.

    a month later

    PavelH I tried your approach and, after much learning and trial & error, was able to get it working exactly the way I wanted. Thanks PavelH.

    Glad to hear that you got things working. Should I close this thread?

      Very welcome. Happy Thanksgiving. (if your in the US... if not well then i feel silly saying that.)

        9 months later

        ntozier can you please help me regarding pulling data of custom fields from database
        Name | Department | Subject | myCustomfield1 | mycustomfield2 |
        XYZ | IT | |Printer | ewewe |

        I want this type of report or extracted data

        Write a Reply...