Search for blank values in custom field

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
Squirt8494
Posts: 9
Joined: Fri Dec 30, 2022 10:06 pm

Search for blank values in custom field

Post by Squirt8494 »

Hi all, I'm looking to do a search for "blank" values, on a custom field.

Reason: I have an "Invoice #" field, and want to quickly show all tickets where the invoice number is blank - and thus unbilled.

Obviously I can do this in an export, but I'm wondering if there's a way to display the results in the normal search function.

The URL format I'm seeing is:

Code: Select all

https://hesk.example.com/admin/find_tickets.php?q=queryTextGoesHere&what=custom1&category=0&owner=0&dt=&s_my=1&s_ot=1&s_un=1&limit=100&more2=0
Image

I've tried searching for !empty(), but that didn't work.

Thank you in advance!
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Re: Search for blank values in custom field

Post by Klemen »

There's currently no built-in way of doing blank searches, but I see its value and will add this to our "to do" list.

For now, what you can do is:

1. download and install Notepad++ (or use some other powerful text editor, do NOT use Microsoft Notepad)
2. open file /admin/find_tickets.php in Notepad++
3. find and delete this code:

Code: Select all

// No query entered?
if ( ! strlen($q) )
{
	$hesk_error_buffer .= $hesklang['fsq'];
	$no_query = 1;
}
4. find this code:

Code: Select all

$sql .= "`".hesk_dbEscape($what)."` LIKE '%".hesk_dbEscape($q)."%' COLLATE '" . hesk_dbCollate() . "' ";
and change it to:

Code: Select all

                if (! strlen($q)) {
                    $sql .= "`".hesk_dbEscape($what)."`='' ";
                } else {
	        	    $sql .= "`".hesk_dbEscape($what)."` LIKE '%".hesk_dbEscape($q)."%' COLLATE '" . hesk_dbCollate() . "' ";
                }

5. save, upload and test
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Squirt8494
Posts: 9
Joined: Fri Dec 30, 2022 10:06 pm

Re: Search for blank values in custom field

Post by Squirt8494 »

That worked brilliantly, thank you! :mrgreen:

In the future, perhaps you could consider combining the search filter fields from "Find a ticket" into the "Show tickets" area, so that grouping, etc. is still possible for results. But I might be missing something bigger.

Thanks again!
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Re: Search for blank values in custom field

Post by Klemen »

We might do that, yes, and offer a "quick global search" field somewhere at the top.

Thanks for the drink!
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post Reply