preload
We have the "Add & Go" and "Search & Go" functionality in Siebel 8. At times, there may arise situations where you need to manipulate the search expression for "Search & Go" applet. Let's consider the following scenario.

We have a "Search & Go" functionality for FAQs on homepage of eService application. This applet has 2 fields - FAQ and Answer. The out of box functionality suffixes the search string of each field with wildcard "*" and also doesn't support field level case insensitivity on VBCs. There are no declarative configurations available currently for this scenario. Hence scripting approach is being used here.

Virtual BC: FAQ Home Search Virtual
Underlying BC: Top 5 FAQ
Fields: FAQ, Answer
Applet: FAQ Home Search Virtual Applet (based on Virtual BC)

In the WebApplet_PreInvokeMethod() of FAQ Home Search Virtual Applet, write the following

if (MethodName == "Mirror Search GotoView")
{
TheApplication().SetSharedGlobal("FAQSearchVirtual", "Y");
}

In the BusComp_PreQuery method of the underlying BC write the following code:

var strSearchExpr = "";
var strNewSearchExpr = "";
var strPattern = "";

if (TheApplication().GetSharedGlobal("FAQSearchVirtual") == "Y")
{
strSearchExpr = this.GetSearchExpr();
strPattern = /(LIKE\s\")/g;
strNewSearchExpr = strSearchExpr.replace(strPattern, "~LIKE \"*");
this.SetSearchExpr(strNewSearchExpr);
TheApplication().SetSharedGlobal("FAQSearchVirtual", "N");
}

The vanilla search expression would like:

[FAQ] LIKE "computer*" AND [Answer] LIKE "electronic*"

This expression returns all the FAQ whose question starts with word "computer" and answer starts with word "electronic". Both are case sensitive.

The above script replace the (LIKE ") with (~LIKE "*). The tilde (~) operator enforces the case insensitivity and * prefix would make the final search expression look like:
[FAQ] ~LIKE "*computer*" AND [Answer] ~LIKE "*electronic*".

This search expression returns all the FAQ where questions case insensitive word "computer" and answer contains case insensitive word "electronic".

More info on Regular Expression for patterns can be found at:
http://www.zvon.org/other/reReference/Output/index.html

Comments/Suggestions are most welcome.