Page 1 of 1

Search for blank values in custom field

Posted: Fri Dec 30, 2022 10:12 pm
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!

Re: Search for blank values in custom field

Posted: Sat Dec 31, 2022 9:08 am
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

Re: Search for blank values in custom field

Posted: Fri Jan 06, 2023 11:18 pm
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!

Re: Search for blank values in custom field

Posted: Sat Jan 07, 2023 9:25 am
by Klemen
We might do that, yes, and offer a "quick global search" field somewhere at the top.

Thanks for the drink!