Page 1 of 1

Searching Custom Fields/Ticket Body

Posted: Fri Sep 07, 2007 10:42 am
by Duckz
Script URL: Internal
Version of script: 0.94
Hosting company: Internal
URL of phpinfo.php: Internal
URL of session_test.php:Internal
What terms did you try when SEARCHING for a solution: Searching Ticket Body, searching custom fields

Write your message below:

Hello there

I have created a custom field called Organisation. Is there any way of searching by this field instead of name/subject? Also is there any way of searching for issues in the ticket body? For ecample, the word SMS Mirror Driver in a ticket, is there a way to list all tickets where this term occurs?

Many Thanks

Lee

Posted: Sat Sep 08, 2007 1:16 am
by rbbigdog
Lee -

Try this...

I believe you'll need to add information for your custom field and message body in the "show_search_form.inc" and the "find_tickets.php" files. I assumed that your custom field "Organization" was "custom1" in the database. If not, change all below references from "custom1" to the right custom number. Always backup your files before making changes (so you can put it back easily if it doesn't work).

Try inserting these bolded lines in the "show_search_form.inc" file:

<tr>
<td class="white"><label><input type="radio" name="what" value="subject"> <b><?php echo $hesklang['subject']; ?></b></label>: &nbsp; </td>
<td class="white"><input type="text" name="subject" size="30" onFocus="Javascript:document.findby.what[3].checked=true;"></td>
</tr>
<tr>
<td><label><input type="radio" name="what" value="custom1"> <b>Organization</b></label>: &nbsp; </td>
<td><input type="text" name="custom1" size="30" onFocus="Javascript:document.findby.what[4].checked=true;"></td>
</tr>
<tr>
<td class="white"><label><input type="radio" name="what" value="message"> <b><?php echo $hesklang['message']; ?></b></label>: &nbsp; </td>
<td class="white"><input type="text" name="message" size="30" onFocus="Javascript:document.findby.what[5].checked=true;"></td>
</tr>
<tr>

<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>


Then insert these bolded lines in the "find_tickets.php" file:

case "subject":
$extra=hesk_input($_GET['subject'],$hesklang['enter_subject']);
$sql .= "`subject` LIKE '%$extra%' ";
break;
case "custom1":
$extra=hesk_input($_GET['custom1'],'Please enter search info for Organization');
$sql .= "`custom1` LIKE '%$extra%' ";
break;
case "message":
$extra=hesk_input($_GET['message'],$hesklang['enter_message']);
$sql .= "`message` LIKE '%$extra%' ";
break;

default:
hesk_error($hesklang['invalid_search']);
}

Give it a try!

RB

Posted: Tue Sep 11, 2007 1:27 pm
by Duckz
This works great, thank you so much.

Lee