Thursday, Oct. 19, 2017

How to Prefix a value to the query string for a field

Written By:

|

August 12, 2012

|

Posted In:

Requirement:

The requirement is to add a prefix to the query string entered by the user on the Last Name field on the Contact BC. Example: If user enters A* , the contacts returned should be of form HD B*. In this example, the prefix is HD.

Solution:

Follow the below steps to implement this trick of adding the prefix value to the query string on a particular field in the BC.

Go to Contacts BC -> Edit Server Scripts and write the below line of code in Pre_Query event of the BC.

function BusComp_PreQuery ()
{
var qstr = this.GetSearchSpec(“Last Name”);   // If User entered A* on UI, in Watch Window it returns:  LIKE B*
var len = qstr.length;      // returns the length of the entered string
var str = “HD”;              // HD is the Prefix value. Change this value as per the requirement
if(qstr != “”)
{
var a = qstr.substring(0,6);            // Break the Search string. In Watch Window it returns: LIKE
var b = qstr.substring(6,len);        // Break the Search string. In Watch Window it returns: B*
var expr = a + str + ” ” + b;            //Form a new expression, In Watch Window it returns: LIKE HD B*
this.SetSearchSpec(“Last Name”, expr);
this.ExecuteQuery(ForwardOnly);
}
return (ContinueOperation);
}
Compile the BC and launch the Siebel Client Application.

Say a user has entered value called B* on the Last Name field on the UI as shown below:

query_prefix1

When User presses Enter key the expected result is below:

query_prefix2

SQL generated in spool will show as below:

query_prefix3



Share This Article

About Author

Gurdeep

Hi, I am sharing my experience to alleviate beginners with open UI and HI version of Siebel CRM. I work in Sun Life Financials and can be reached via IT Tool box as well. Thanks.

Comments are closed.

Leave A Reply