Hi guys,

I installed osTicket 1.14.3 on our company webserver and so far everything has been working great, but before I can put it to use I need to solve a problem.

Our users/customers all have a unique ID number in the format nnxxxxxxxx, where x is a number and nn are two letters.
I went to Admin panel > Manage > Forms > User Information and added a new required field (type Short Answer, field length 10).
This works: when I create a new user the custom field shows up and I'm able to save it along with the other form data.

However, when I go to Users > User Directory and search for the ID number in the search field I get zero results.
I also can't look up a user by ID.

Is there a way to make osTicket index this field? Maybe by modifying a php file or MySQL setting?

Thanks in advance for your help.

Kind regards,

Paul

Technical info:

osTicket Version: v1.14.3 (f4f5bc6)
Web Server Software: Apache
MySQL Version: 10.3.23
PHP Version: 7.3.21

@CMPaul

You will have to customize the code to accomplish this.

You can look at include/staff/users.inc.php and see on line 13 where the ORM statement is defined. You can do something like the following:
After line 19 you can add the following where variablename is the custom field's variable name:

     if (UserForm::getInstance()->getField('phone'))
         $filter->add(array('cdata__phone__contains' => $search));
+     
+     $filter->add(array('cdata__variablename__contains' => $search));

Cheers.

    Hi Kevin,

    I noticed that the search for the custom field doesn't work in the (modal) popup window titled 'Lookup or create a user'. I assume I have to alter another php file for this to work, but which one is it? Thanks in advance for your help.

    6 months later

    @CMPaul,

    I had the same issue as you and figured this out. You need to do the procedure in this blog post. You need to find the file include/ajax.users.php as this is the file that handles the ajax requests from the users form. On line 83 there's something similar to the code below:

    if (UserForm::getInstance()->getField('phone')) {
    	UserForm::ensureDynamicDataView();
    	$filter->add(array('cdata__phone__contains' => $q));
    }

    I just copy and pasted that code into the line below the phone code and replaced "phone" with my variable name:

    if (UserForm::getInstance()->getField('variableName')) {
    	UserForm::ensureDynamicDataView();
    	$filter->add(array('cdata__variableName__contains' => $q));
    }

    That change allowed me to type my custom variable values into the user search modal when creating new tickets and if I closed the modal, it worked from the user line as well. Make sure your custom variable values are at least three characters in length, though. The ajax search will not start looking until you've got three characters.

    Note: I was using osTicket 1.15, but the locations of these code items should be pretty close to where these were with older versions of the files.

    Write a Reply...