Siebel Tools >  Build a search query with e Script

Build a search query with e Script

One of the things that you will need to know is how to run an SQL against a Siebel Database.

In Escript, we need to create a search specification rather than use SQL syntax. The Search specification can be increased by using a + symbol to make more specifications in the query.

The example below shows how we could find an account using Account number, Full name, Account status, email address and full address of an account in a Siebel database.

 

if the account is found, then Siebel will show a popup and say 'Account found'.

try{

var AccountNumber :chars = this.GetFieldValue("Account Number");

var CompanyName :chars = this.GetFieldValue("Full Name");

var Stage :chars = this.GetFieldValue("Account Status");

var EmailAddress :chars = this.GetFieldValue("Email Address");

var Address :chars = this.GetFieldValue("Full Address");

var SearchSQL :chars = "";

var BusinessObject :BusObject = TheApplication().GetBusObject("Account");

var BusinessComp :BusComp = BusinessObject.GetBusComp("Account");

SearchSQL = "[Account Number]='" + AccountNumber +  "' AND [Full Name]<>'" + CompanyName + "' AND [Account Status]='" + Stage + "'  AND [Email Address]='" + EmailAddress + "'  AND [Full Address] <> 'Address' ";


with(BusinessComp)

{

          ClearToQuery(); SetSearchExpr(SearchSQL);

          ExecuteQuery(ForwardOnly);

    if(FirstRecord())

    {

       TheApplication().RaiseErrorText(TheApplication().MessageBox("Account found"));

     }

}


}

 

catch(e)

       {

              // show error text

              throw e;

         }

finally

        {

             BusinessComp = null;

             BusinessObject = null;

          }