Building a Simple Quick Search Page

2 minute read time.

Entities such as Case and Solution use a reference field as an alternative key. This is the 'ticket' number (case_referenceid, soln_referenceid) that is used as a public and convienent way of identifying each record.

In the default demo system the fields case_referenceid and soln_referenceid are based on the CRM field type of 'StoredProc'. The reference ids are generated by a stored procedure and the pattern of the reference id can be whatever the customer implementation requires. e.g. userid-uniquenumber, 3-1253 or year-userinitials-number, 2009/WK/1253. I have discussed in previous articles how fields using the 'StoredProc' field type can be configured. It allows the reference id to contain more information than the simple primary key value.

All this means is that a case (or a solution) can be uniquely identified using the reference id (Ticket Number) and any correspondence with a customer is going to use that reference id.

A site that uses Sage CRM for the management of its Support Tickets and Customer Service Requests asked me whether if there was a quick way of looking up the next case while in another one. The support engineers wanted the ability to quickly type in just the reference id and go straight to the next case.

This would be useful as it would be much quicker than going Find -> Case and having to wait for the last search to return results. This is a site that often has a case reference for the case that need to access and so don't need any more options than just that ticket number.

The example I provided to them was an extra button on the case summary screen.

Once the Quick Find button was pressed the Customer Service Agent could enter the next Case Reference/Ticket number and click find.

This will then move the screen to the next case.

Solution

The Quick Find button was added to the Case Summary screen using the feature 'Button Groups'. You can find example of how to do that on this site.

I used an ASP page to build the behaviour. This could equally done using the .NET API.

Below is the code used.


<%

if (CRM.Mode==View)
{
CRM.Mode = Edit;
}
var SearchBlock = CRM.GetBlock("entrygroup");
var fieldCaseRef = CRM.GetBlock("entry");
with (fieldCaseRef)
{
EntryType = 10;
DefaultType = 1
FieldName = "case_reference";
Caption = "ReferenceID";
Required = true;
}
SearchBlock.AddBlock(fieldCaseRef);
SearchBlock.Title="Enter Reference";
var myBlockContainer = CRM.GetBlock("Container");
with (myBlockContainer)
{
AddBlock(SearchBlock);
ButtonTitle = "search";
ButtonImage = "search.gif";
}
var strCaseRef = Request.Form("case_reference");
var Arg = "case_referenceid = '"+strCaseRef+"'";

var caseRecord = CRM.FindRecord("cases",Arg);
if (!caseRecord.eof)
{
//Response.Redirect(CRM.URL(281)+" &Key8="+caseRecord.case_caseid);
Response.Redirect("/"+sInstallName+"/eware.dll/Do?SID="+Request.QueryString("SID")+" &Act=281 & &Mode=1 &CLk=T &Key0=8 &Key8="+caseRecord.case_caseid);

}

CRM.AddContent(myBlockContainer.Execute());
Response.Write(CRM.GetPage());

%>

The code uses a custom build entry screen to display an entry field for the case reference id. If the search finds a record then it will redirect to the Summary screen for the case. The URL has been built in such as way as the existing Case primary key is not included in the URL and so avoids any clash. This is highlighted in the code above.

Note:

This is not a complete solution. This can be further developed by embedding a search box into the custom content of the summary using an which would remove one more click and keep the first case's details on screen until the search is successful.

But that is a little more work and is for another time.