Invoking a Business Service from a SmartScript
You can invoke a business service from a SmartScript by using Siebel VB or Siebel eScript to make call statements for the required business service. This allows you to reuse code. The following example code retrieves information from a SmartScript and invokes the Universal Inbox business service to create a new item in the Inbox. For another example, see Invoking Siebel Assignment Manager.
function Script_Finish ()
{
var szScriptSessionId;
var szRequester;
var svc;
var indata;
var outdata;
var ssPage;
var ssQuestion;
var EmployeeLastName;
var EmployeeFirstName;
var RequestedChange;
var PAFComments;
var PAFPriority;
var szSSLanguageCode;
var szSSCurrencyCode;
ssPage = GetPage("PAF Which Change");
ssQuestion = ssPage.GetQuestion("Display Employee Last Name");
EmployeeLastName = ssQuestion.GetCurrentValue();
ssQuestion = ssPage.GetQuestion("Display Employee First Name");
EmployeeFirstName = ssQuestion.GetCurrentValue();
ssQuestion = ssPage.GetQuestion("PAF Change Requested");
RequestedChange = ssQuestion.GetCurrentValue();
ssQuestion = ssPage.GetQuestion("PAF Comments");
PAFComments = ssQuestion.GetCurrentValue();
ssQuestion = ssPage.GetQuestion("PAF Priority");
PAFPriority = ssQuestion.GetCurrentValue();
// Cancel saving everything to the database
Cancel ();
indata =TheApplication ().NewPropertySet ();
outdata = TheApplication ().NewPropertySet ();
// Get the login name of the user
szRequester = TheApplication ().LoginName ();
// Get SmartScript Save Session table Id.
szScriptSessionId = GetSessionId ();
szSSLanguageCode = GetParameter("Language");
szSSCurrencyCode = GetParameter("Currency");
indata.SetProperty ("SmartScriptLanguageCode", szSSLanguageCode);
// ItemObjectId, ItemType, ItemSubmittedBy, and ItemDescription are the
// required input arguments for the "Universal Inbox.Initialize"
indata.SetProperty ("ItemObjectId", szScriptSessionId);
// Item Type is the Approvals Inbox type defined in the
// Approvals Inbox Administration screen
indata.SetProperty ("ItemType", "Personnel Action Form");
// Short Description of the inbox item
indata.SetProperty ("ItemDescription", RequestedChange + " PAF" + " for " +
EmployeeFirstName + " " + EmployeeLastName);
indata.SetProperty ("ItemSubmittedBy", szRequester);
// ItemQueueDuration, ItemPriority, and ItemComments are the
// optional input arguments for the "Universal Inbox.Initialize"
indata.SetProperty ("ItemQueueDuration", "129600");
indata.SetProperty ("ItemPriority", PAFPriority);
indata.SetProperty ("ItemComments", PAFComments);
svc = TheApplication ().GetService ("Universal Inbox");
svc.InvokeMethod("Initialize", indata, outdata);
var id = GetSessionId ();
var bo = TheApplication().GetBusObject("Smart Scripts");
var bc = bo.GetBusComp("Call Script Runs");
bc.ActivateField("Status Code");
bc.SetSearchSpec("Id", id);
bc.ExecuteQuery();
if (bc.FirstRecord())
bc.SetFieldValue("Status Code", "Finished");
bc.WriteRecord();
}