8Extending Scripts with Siebel VB and Siebel eScript
Extending Scripts with Siebel VB and Siebel eScript
This chapter describes how you can extend the functionality of your SmartScripts using Siebel eScript or Siebel Visual Basic (VB). It includes the following topics:
About Siebel VB and Siebel eScript
You can use Siebel VB and Siebel eScript (a scripting language like JavaScript) with all SmartScript elements. This topic describes the Siebel VB and Siebel eScript events that are specific to SmartScripts. The syntax for all of these events is the same in both Siebel VB and Siebel eScript. Most of the examples in this chapter are in Siebel VB. However, the events work the same way in Siebel eScript. For more information about Siebel VB and Siebel eScript, see the following guides:
Siebel Object Interfaces Reference
Siebel VB Language Reference
Siebel eScript Language Reference
Any function that can be performed using Siebel VB or Siebel eScript can be performed in the context of a SmartScript or a call script. In addition, SmartScripts are automatically configured with Siebel VB and eScript events, which can be added to a question or script using the SmartScript Script Programs view and Question programs view. In addition, administrators can create their own custom procedures from these views. The following information lists the standard Siebel VB and Siebel eScript events that are used in SmartScript events.
Table Standard Siebel VB and Siebel eScript Events Used in SmartScripts
Name | Role |
---|---|
Script_Open |
A postevent function called when the script is opened. |
Script_Cancel |
A postevent function called when the script is canceled. |
Script_PreFinish |
A preevent function called when the user clicks the Finish button. |
Script_Finish |
A postevent function called after the script has been finished, but before data is saved to allow a last-minute cleanup or postprocessing. |
Script_Save |
An event function called before the normal script state has been saved to the business components and the answer table, and after the Script_Finish function has run. |
Each question element is configured with four events. Other elements do not have Siebel VB or Siebel eScript events associated with them. These events can contain methods that can be used to further control the workflow of a script. The following table lists the standard Siebel VB and Siebel eScript events that are used in SmartScript Questions.
Table Standard Siebel VB and Siebel eScript Events Used in SmartScript Questions
Name | Role |
---|---|
Question_Enter |
A postevent function called after the question has been entered and all pre-question processing is complete. |
Question_PreLeave |
A preevent function called on the question before the user leaves it by jumping or proceeding (but not by Undo or Backup). |
Question_Leave |
A postevent function called after branching has been determined and all built-in validations have been performed. |
Question_PreBranch |
A preevent function that allows the choice of answer to be replaced by the Siebel VB or Siebel eScript script. |
About SmartScript Object Types
Within a script, you can refer to virtual business components in the same way that you refer to other business components. Virtual business components are a class of business component that access external data (data stored outside the Siebel database). Virtual business components allow you to present and manipulate external data using the Siebel user interface without having to replicate the data inside the Siebel data model.
Siebel VB and Siebel eScript recognize the following items as SmartScript object types:
SmartScript
SmartScriptPage
SmartScriptQuestion
SmartScriptAnswer
Accessing the Scripting Area
This topic describes how you access the scripting area in the Administration - SmartScript screen. The view that you access in this screen depends on whether you want to add script to a script or to a question.
To access the scripting area
Navigate to the Administration - SmartScript screen.
Select the option from the following table that applies to you.
If you want to ... Then ... Add scripting to a SmartScript object
Navigate to the Scripts view > Programs subview
Add scripting to a SmartScript Question object
Navigate to the Questions view > Programs subview
Create a new record in the Programs view, select the event type from the Name drop-down list, and the Script language from the Program Language drop-down list.
Click Save in the Programs view.
Add your script in the Scripts text area that appears after the Programs subview.
Note: Each script has the option of using the Siebel VB or Siebel eScript languages. However, you must use the same language throughout a script. For a question, you also have the option of using Siebel VB or Siebel eScript. Every question method has to use the same language for each question. This means that the languages can be different for different questions, but within the same question, the languages must be the same.
SmartScript Events
You can configure how the SmartScripts respond to an event, using the Programs subview of the Administration - SmartScript screen > Scripts view.
The following topics describe the available events:
Script_Open
Script_Open allows updating of the Customer Dashboard. You can also position the database on the appropriate record when saving the answers to a business component.
Syntax
Script_Open
Returns
Not applicable
Usage
Script_Open allows you to set the variables in complex branching, in later questions, or in the Customer Dashboard. You can also use it to create a new record and populate some values using code.
Script_Cancel
Script_Cancel handles postprocessing when a script is canceled.
Syntax
Script_Cancel
Returns
Not applicable
Usage
This postevent is called to allow any last-minute cleanup or postprocessing when the script is canceled. Script_Cancel is not called if Cancel is called from the Script_Open event. If an error is raised during the Script_Cancel procedure, the error is rolled back.
Script_Pre Finish
Script_PreFinish is called when a script is finished.
Syntax
Script_PreFinish
Returns
An enumerated value indicating one of the script state indicators:
Value | Indicator | Description |
---|---|---|
0 |
ContinueOperation |
Continue to Script_Finish |
1 |
CancelOperation |
Cancel operation |
2 |
OperationComplete |
Skip Script_Finish |
Usage
Script_PreFinish is called when the user wants to finish the SmartScript (by clicking the Finish button). This is a good place to check additional constraints on the SmartScript that were not set up through configuration. Script_PreFinish is declared as an integer.
Script_Finish
Script_Finish allows cleanup after a script is finished.
Syntax
Script_Finish
Returns
Not applicable
Usage
Script_Finish is a postevent that is called to permit any last-minute cleanup or postprocessing after the script has been finished. If an error is raised during the procedure, it is displayed to the user, but the script remains finished.
Script_Save
Script_Save can be used to save states not stored by normal means.
Syntax
Script_Save
Returns
Not applicable
Usage
Script_Save is an event called before the normal script state has been saved to business components and the answer table, and after Script_Finish has been called. This is a good place to save additional states collected by the SmartScript and not stored by the normal mechanisms.
SmartScript Methods
You can use the following SmartScript methods with any of the events that you access from the Programs subview of the Administration - SmartScript screen > Scripts view. For more information about these events, see SmartScript Events. The available methods are:
Cancel
Cancel cancels the current script.
Syntax
Cancel
Returns
Not applicable
Usage
The Cancel method stops the SmartScript’s execution. This method cancels only the SmartScript’s execution. It does not take you back to the original view or, as with the Cancel button, take you to the specified OnCancel view.
CurrentPage
CurrentPage returns the current page of the executing SmartScript.
Syntax
CurrentPage
Returns
The name of the current page of the executing SmartScript.
Usage
CurrentPage is declared as a SmartScriptPage object.
CurrentQuestion
CurrentQuestion returns the current question of the executing SmartScript.
Syntax
CurrentQuestion
Returns
The current question of the executing SmartScript.
Usage
The CurrentQuestion method returns the current question of the executing SmartScript. This method always returns a question object if the script is actively executing. The CurrentQuestion is declared as a SmartScriptQuestion object.
ExecutionState
ExecutionState returns the current state of a running SmartScript.
Syntax
ExecutionState
Returns
A representation of the current state of the SmartScript as an integer value. The values are represented by the following constants, each of which is followed by its integer equivalent:
Script State | Integer Value |
---|---|
Not available |
0 |
ssInitializing |
1 |
ssRunning |
2 |
ssFinished |
3 |
ssCanceled |
4 |
Usage
ExecutionState returns zero (0) if the SmartScript object has not been specified to execute (used when listing available SmartScripts).
Finish
Finish causes the current script to finish.
Syntax
Finish
Returns
Not applicable
Usage
The Finish method causes the currently running script to finish. The collected answers are saved as appropriate. This method can fail if the user has not answered all the questions that require answers (must answer questions).
GetCampaignId
GetCampaignId returns the campaign identification string.
Syntax
GetCampaignId
Returns
The campaign ID as a string.
Usage
GetCampaignId returns the campaign ID created when a script is launched from Siebel Campaigns, Siebel CTI, or the SetCampaignID method. This information, if available, is stored in the SmartScript session for calls.
Siebel VB Example
Dim CampaignId as String CampaignId = Script.GetCampaignIdSee Also
GetCampContactId
GetCampContactId returns the campaign contact identification string.
Syntax
GetCampContactId
Returns
The campaign contact ID as a string.
Usage
GetCampContactId returns the campaign contact ID for the campaign contact as set up by launching a script from Siebel Campaigns, Siebel CTI, or the SetCampContactID method. This information, if available, is stored in the SmartScript session for calls.
GetContactId
GetContactId returns the contact identification string.
Syntax
GetContactId
Returns
The contact ID as a string.
Usage
GetContactId returns the contact ID as set up by launching a script from Siebel Campaigns, Siebel CTI, or the SetContactID method. This information, if available, is stored in the SmartScript session for calls.
GetLabelText
GetLabelText returns the translation of the current script name in the current language.
Syntax
GetLabelText
Returns
Language-specific label text for the script as a string.
Usage
GetLabelText is used when displaying script names as in the Choose SmartScript dialog box.
GetPage
GetPage returns a page of the script by name.
Syntax
GetPage(name)
Argument | Description |
---|---|
name |
The name of a SmartScript page as a string |
Returns
A page of the script as a SmartScriptPage object.
Usage
This method returns a page of the script when the page name is specified. This name is the nontranslated name set during authoring, not the label of the page tab displayed for a particular language.
Siebel VB Example
Dim IntroductionPage as SmartScriptPage Set IntroductionPage = GetPage("Introduction")See Also
CurrentPage and Page.
GetParameter
GetParameter retrieves a value that has been assigned to a specified user parameter, a CTI switch parameter, or a system parameter.
Syntax
GetParameter(ParameterName)
Argument | Description |
---|---|
ParameterName |
The name of a system parameter as a string |
Returns
The value of the specified parameter as a string.
Usage
You use GetParameter to retrieve a value assigned to a user parameter. The parameter name in this case must be prefixed with User. Usually a value is stored by using the SetUserParameter function.
You use GetParameter to retrieve the current setting of a Siebel CTI switch parameter. The parameter name in this case must be prefixed with CTI. CTI switch parameters are set when SmartScript is invoked using the Siebel Communications Server. For more information, see Siebel CTI Administration Guide.
You use this parameter to retrieve the value of a system parameter. The following information lists the system parameters.
Table System Parameters
System Parameter Name | Usage Definition |
---|---|
CampaignId |
Set when SmartScript is invoked using Siebel Communications Server. |
CampConId |
Set when SmartScript is invoked using Siebel Communications Server. |
ContactId |
Set when SmartScript is invoked using Siebel Communications Server. |
ScriptId |
Script row ID. |
ScriptName |
Script name. |
ScriptLabel |
Script’s translation (label). |
Language Code/Language |
Language in which the script is running. |
Currency Code/Currency |
Default currency. |
System.RecordFound |
Set to TRUE if records are returned from the search spec defined on the question; set to FALSE otherwise. |
Siebel VB Example
Dim ContactId as String ContactId = GetParameter("ContactId") SetUserParameter "ContactId", ContactId GetParameter("CTI.ANI")See Also
GetQuestion
GetQuestion returns a question of the script by name.
Syntax
varPage.GetQuestion(name)
where varPage is the Page object.
Argument | Description |
---|---|
name |
The name of a SmartScript question as a string |
Returns
A question of the script as a SmartScriptQuestion.
Usage
Specify the name of the question as a parameter to the GetQuestion method to retrieve the question as a SmartScriptQuestion. The name you specify is the nontranslated name set during authoring, not the question text displayed for a particular language. GetQuestion is declared as a SmartScriptQuestion.
You must also specify the page where the question appears. If the question appears on the current page, you do this as follows:
var Question = Page().GetQuestion ("Name of question");
If the question appears on another page, you must retrieve this page as in the following example:
var p=Script().GetPage("Other page name"); var Question = p.GetQuestion ("Name of question");
Dim ContactQuestion as SmartScriptQuestion Set ContactQuestion = myPage.GetQuestion("First Name")
See Also
GetSessionId
GetSessionId returns a row ID of the session table where the script answers are stored.
Syntax
GetSessionId
Returns
The row ID of the session table where the script answers are stored according to the script's administration settings (Save Session column on the script and Save Answer Table flag on the script's questions). It returns a string. It is empty if the script is not set to save the session, or if GetSessionId is called from incorrect events.
Usage
GetSessionId is declared as a string. Call this method from either Script_Finish or Script_Save events.
Siebel VB Example
Dim ScriptSessionId as String ScriptSessionId = GetSessionId()
Var ScriptSessionId; ScriptSessionId = GetSessionId();
OriginalDashboardText
OriginalDashboardText returns the text in the dashboard field for the currently running translation.
Syntax
OriginalDashboardText
Returns
The text of the Customer Dashboard that was originally configured as a string.
Usage
This method returns the configured value of the Dashboard text (Descriptive Text).
SetCampaignId
SetCampaignId sets the campaign ID if obtained using script execution.
Syntax
SetCampaignId(ID )
Argument | Description |
---|---|
ID |
The ID of the sales or marketing campaign as a string |
Returns
Not applicable
Usage
SetCampaignId sets the campaign ID if obtained using script execution. This information is stored in the SmartScript session.
See Also
SetCampContactId
SetCampContactId sets the campaign and contact ID, if gathered using script execution.
Syntax
SetCampContactId(ID )
Argument | Description |
---|---|
ID |
The ID of the sales or marketing campaign and the contact as a string |
Returns
Not applicable
Usage
SetCampContactId sets the campaign and contact ID if obtained using script execution. This information is stored in the SmartScript session.
SetContactId
SetContactId sets the contact ID.
Syntax
SetContactId(ID)
Argument | Description |
---|---|
ID |
The ID of the contact as a string |
Returns
Not applicable
Usage
SetContactId sets the contact ID if obtained using script execution. This information is stored in the SmartScript session.
SetUserParameter
SetUserParameter assigns a value to a specified user parameter.
Syntax
SetUserParameter ParameterName, value
Argument | Description |
---|---|
ParameterName |
The name of a user parameter as a string |
value |
The value to be assigned to ParameterName as a string |
Returns
Not applicable
Usage
Use SetUserParameter to assign the value returned by GetParameter to a user parameter. SetUserParameter is declared as a string.
Siebel VB Example
If ContactExists then SetUserParameter "ContactExists", "Y" else SetUserParameter "ContactExists", "N" ContactBC.NewRecord NewBefore end if
See Also
StartPage
StartPage returns the configured name of the start page on the SmartScript itself.
Syntax
StartPage
Returns
The configured name—the original name before any translation—of the start page of the current SmartScript as a SmartScriptPage object.
Usage
StartPage is declared as a SmartScriptPage object.
StartQuestion
StartQuestion returns the configured name of the starting question on the SmartScript itself.
Syntax
StartQuestion
Returns
The configured name—the original name before any translation—of the first question of the current SmartScript as a SmartScriptQuestion object.
Usage
StartQuestion is declared as a SmartScriptQuestion object.
SubstituteText
Syntax
SubstituteText(text, “variable”, “value” )
Argument | Description |
---|---|
text |
A block of text, including the variable to be replaced. |
variable |
A string whose content is to be replaced by value. |
value |
The new text string to be inserted in the original block of text in place of variable. |
Returns
The original block of text with the new value substituted for the variable as a string.
Usage
This method substitutes a single string in the Text, found as [Variable] with the Value, and returns the changed text. In the text variable, the variable and the value are enclosed in brackets ([ ]).
Siebel VB Example
The phrase “Are you calling from your car?” is rendered as “Are you telephoning from your carriage?” if the function was configured to translate from U.S. English to Victorian English as follows:
Dim VehCheck as String VehCheck = “Are you [phone] from your [vehicle]?" if (Victorian) then VehCheck = SubstituteText(VehCheck, “phone", “telephoning") VehCheck = SubstituteText(VehCheck, “vehicle", “carriage") else VehCheck = SubstituteText(VehCheck, “phone", “calling") VehCheck = SubstituteText(VehCheck, “vehicle", “car") end if
SmartScript Page Methods
The SmartScript Page object type represents a single page of the SmartScript being executed. pages pages methods used with
You can invoke the following methods on the SmartScript Page object:
GetHelpText
If any help text is present, GetHelpText returns the help text for the current page in the current language.
Syntax
GetHelpText
Returns
The language-specific help text associated with the page as a string.
Usage
Help text can be used as reference help text that can be captured and displayed to a user using VB within a question text.
GetLabelText
GetLabelText returns the translation of the current page name in the current language.
Syntax
GetLabelText
Returns
The translation of the name of the current page of the current SmartScript in the current language as a string.
Usage
GetLabelText returns the language-specific translation for the page name. This text is displayed in the page tab and can be used in error messages or other user interactions.
GetQuestion
GetQuestion returns the text of the specified question.
Syntax
GetQuestion(QuestionName)
Argument | Description |
---|---|
QuestionName |
The name of a question |
Returns
The question whose name is the parameter as a string.
Usage
GetQuestion is declared as a SmartScriptQuestion object.
GetQuestion returns the text of a question on the page when the question name is specified. This name is the nontranslated name set during authoring. It is not the question text displayed for a particular language.
Script
Script returns the name of the script containing the page.
Syntax
Script
Returns
The name of the script containing the current page as a SmartScript object.
Usage
Script is declared as a SmartScript object.
StartQuestion
StartQuestion returns the starting question on the current page.
Syntax
StartQuestion
Returns
The first question of the current page.
Usage
StartQuestion is declared as a SmartScriptQuestion object.
SmartScript Question Events
You can configure how SmartScript Questions respond to certain events by writing code in the Programs subview of the Administration - SmartScript screen > Question view. The available events are:
Question_Enter
Question_Enter is called when the processing of a question is complete.
Syntax
Question_Enter
Returns
Not applicable
Usage
This postevent is called after the question has been entered and all pre-question processing is complete. This is a good place to change the question text or set the current value.
Question_Pre Leave
Question_PreLeave is a preevent called by certain methods before the user leaves a question.
Syntax
Question_Pre Leave
Returns
Not applicable
Usage
This preevent is called on the question before the user leaves it by jumping or proceeding (but not by Undo or Backup). This allows question-specific validation to be performed.
Siebel VB Example
Function Question_PreLeave () As Integer Script.SetUserParameter "Current Product", GetCurrentValue Question_PreLeave = ContinueOperation End Function
Question_PreBranch
Question_PreBranch lets a question be replaced, for purposes of choosing a branch, by the results of this function.
Syntax
Question_PreBranch(answer)
Argument | Description |
---|---|
answer |
The answer given to the question as a string. |
Returns
An evaluation of an answer, which is represented by an integer.
Usage
Question_PreBranch replaces the answer to a question by the results of this method. It is declared as an integer. The normal branching logic of matching answers to branches is performed, unless that event is overridden by this function. The final value of the Answer argument is compared with the answers given to determine which branch is to be taken out of this question. This allows programmatic processing to determine branching (among preconfigured branches), regardless of the answer that is stored. The value returned in the parameter is not stored as the answer to the question, but is used to choose the answer used for branching.
For example, if the caller supplies a bank account number, the function evaluates the number to determine what type of account it is and branches to questions for that type of account. The answer stored in the database, however, is the account number given.
Question_Leave
Question_Leave is called after branching from the question.
Syntax
Question_Leave
Returns
Not applicable
Usage
Question_Leave is called on the question after branching has been determined and all the built-in validations have been performed.
Siebel VB Example
Sub Question_Leave Dim ProductDesc As String ProductDesc = Page.GetQuestion("Choose Product").GetCurrentValue Script.SetUserParameter "ProductDesc", ProductDesc End Sub
SmartScript Question Methods
You can invoke the following methods on the SmartScript Question object: questions; question methods
AnswerType
AnswerType returns the data type of the answer.
Syntax
Answer Type
Returns
An integer representing a data type as indicated in the following table.
Answer Type | Integer Value |
---|---|
ssString |
1 |
ssInteger |
2 |
ssNumber |
3 |
ssCurrency |
4 |
ssBoolean |
5 |
ssDate |
6 |
ssTrue |
7 |
ssDateTime |
8 |
ssInformation |
9 |
Usage
AnswerType returns the data type of the answer that the current question collects. Each data type is represented as an integer in the return value. AnswerType is declared as an integer.
CurrencyFieldName
CurrencyFieldName returns the name of the field in which the currency code is stored.
Syntax
CurrencyFieldName
Returns
The name of the field in which the currency code is stored as a string.
Usage
CurrencyFieldName returns the configured field name in which the currency code is stored. It is declared as a string. You can use this method only with questions that accept currency values (AnswerType = ssCurrency).
GetCurrentCurrencyCode
GetCurrentCurrencyCode returns the most recent currency code.
Syntax
GetCurrentCurrencyCode
Returns
The currency code entered in response to the current question as a string.
Usage
GetCurrentCurrencyCode returns the current currency code entered by the user for a question if it is a currency question. The currency code might have changed many times as the user worked through the script. GetCurrentCurrencyCode is declared as a string.
See Also
GetCurrentExchangeDate
GetCurrentExchangeDate returns the exchange date for the most recent currency question.
Syntax
GetCurrentExchangeDate
Returns
The current currency exchange date entered in response to the current question as a string.
Usage
GetCurrentExchangeDate returns the current, currency exchange date entered by the user for this question (if it is a currency question). This might have changed many times as the user worked through the script. GetCurrentExchangeDate is declared as a string.
See Also
GetCurrentValue
GetCurrentValue returns the current answer to the current question.
Syntax
GetCurrentValue
Returns
The current value entered in response to the current question as a string.
Usage
GetCurrentValue returns the current value entered by the user for this question. This may have changed many times as the user worked through the script. GetCurrentValue is declared as a string.
Siebel VB Example
Sub Question_Leave if GetCurrentValue() = "Y" then Script.Finish TheApplication.InvokeMethod "RunSmartScript", "Voicemail", "", "ENU", "USD" end if
See Also
GetHelpText
If any help text is present, GetHelpText returns the help text for the current question in the current language.
Syntax
GetHelpText
Returns
The language-specific help text associated with the question as a string.
Usage
Help text can be used as reference help text, which can be captured and displayed to a user using VB within a question text.
GetInitialCurrencyCode
GetInitialCurrencyCode returns the currency code for the question before the script was executed.
Syntax
GetInitialCurrencyCode
Returns
The initial currency code for the question as a string.
Usage
GetInitialCurrencyCode returns the currency code for the question (if it is a currency question) before the user started executing the script. This value is usually null unless the value came from a business component field or was set up by Siebel VB or Siebel eScript in a Script_Open procedure. GetInitialCurrencyCode is declared as a string.
See Also
GetInitialExchangeDate
GetInitialExchangeDate returns the exchange date of a currency question before the script was executed.
Syntax
GetInitialExchangeDate
Returns
The initial currency exchange date for a currency question as a string.
Usage
This function returns the initial currency exchange date for this question (if it is a currency question) before the user started executing the script. This value is usually null unless the value came from a business component field or was set up by Siebel VB or Siebel eScript in a Script_Open procedure. GetInitialExchangeDate is declared as a string.
See Also
GetInitialValue
GetInitialValue returns the value of an answer before the script was executed.
Syntax
GetInitialValue
Returns
The initial value for the question as a string.
Usage
GetIntialValue returns the value for the question before the user started executing the script. This value is usually null unless the value came from a business component field or was set up as a Default Answer in the SmartScript Question Administration view or by Siebel VB or Siebel eScript in a Script_Open procedure. It is declared as a string.
See Also
GetPriorCurrencyCode
GetPriorCurrencyCode returns the currency code entered the previous time that the question was reached.
Syntax
GetPriorCurrencyCode
Returns
The previous currency code for the question as a string.
Usage
This method returns the currency code for the question (if it is a currency question) before the user reached it the previous time. The value returned will be either the same value as returned by GetInitialCurrencyCode, if the user has never entered the question, or the value as returned by GetCurrentCurrencyCode, after the user left it the last time. The function is usually used only for the current question. GetPriorCurrencyCode is declared as a string.
See Also
GetPriorExchangeDate
GetPriorExchangeDate returns the exchange date code used the previous time a question was reached.
Syntax
GetPriorExchangeDate
Returns
The previous exchange date code for the question as a string.
Usage
GetPriorExchangeDate returns the currency exchange date for this question (if it is a currency question) before the user reached it most recently. The value returned will be either the same value as returned by GetInitialExchangeDate, if the user has never entered the question, or the value as returned by GetCurrentExchangeDate after the user left it the last time. This function is usually used only for the current question. GetPriorExchangeDate is declared as a string.
See Also
GetPriorValue
If the user has reached the question more than once, GetPriorValue returns the previous answer.
Syntax
GetPriorValue
Returns
The prior value of the question as a string
Usage
GetPriorValue returns the value for this question before the user reached it most recently. The value returned will be either the value returned by GetInitialValue, if the user has never entered the question, or the value returned by GetCurrentValue, after the user left it the last time. This function is usually used only for the current question. GetPriorValue is declared as a string.
See Also
GetQuestionEnable
The GetQuestionEnable method returns the enable state of the current question.
Syntax
GetQuestionEnable
Returns
TRUE if the question is enabled and FALSE if the question field is disabled.
Usage
The GetQuestionEnable method returns the enable state of the current question. When the question is enabled, the user can modify the question's answer. If the question is disabled, the question's answer is read-only.
Siebel VB Example
if GetQuestionEnable = TRUE then Script.SetUserParameter “Order_Product_Enabled", “Yes" end if
GetQuestionText
GetQuestionText returns the text of a question.
Syntax
GetQuestionText
Returns
The displayed text of the question as a string.
Usage
GetQuestionText returns the displayed question text. (The original configured text can be retrieved with OriginalQuestionText.) It is declared as a string.
Siebel VB Example
Sub Question_Enter Dim QuestionText as String QuestionText = GetQuestionText End Sub
See Also
SubstituteText, OriginalQuestionText, and SetQuestionEnable.
GetSaveBusComp
GetSaveBusComp returns the business component that was configured to store the answer.
Syntax
GetSaveBusComp
Returns
The instance of the business component in which the answer is to be stored as a business component.
Usage
GetSaveBusComp returns the instance of the business component used to store the answer in. If no field and business component are configured on this question, it returns NULL. GetSaveBusComp is declared as type BusComp.
Siebel VB Example
Dim BC as BusComp Dim Q as SmartScriptQuestion Set Q = Page.GetQuestion("Intake Interview: Patient Name") Set BC = Q.GetSaveBusComp BC.NewRecord NewBefore
See Also
GetSaveBusObj
The GetSaveBusObj method returns the business object configured to store the answer.
Syntax
GetSaveBusObj
Returns
The instance of the business object in which the answer is to be stored as a BusObj.
Usage
This function returns the instance of the business object used to store the answer. If no business component or business object is configured on this question, it returns a null set. GetSaveBusObj is declared as type BusObj.
See Also
HasDefaultAnswer
HasDefaultAnswer returns a Boolean value indicating whether the question has a default answer.
Syntax
HasDefaultAnswer
Returns
TRUE if the question is configured with a default answer, or FALSE if it is not.
Usage
HasDefaultAnswer is declared as Boolean.
MustAnswer
MustAnswer returns a value indicating whether the question is required.
Syntax
MustAnswer
Returns
One of the integer values indicated in the following table.
Return Value | Description |
---|---|
0 |
The question is optional. |
1 |
The question is required. |
2 |
The question is required when reached. |
Usage
This function returns one of three values indicating whether the question is set to optional, required, or answer if it is reached.
OriginalQuestionText
OriginalQuestionText returns the original text of the question.
Syntax
OriginalQuestionText
Returns
The configured value of the question text as a string.
Usage
This function returns the configured value of the question text. (The value displayed is obtained using GetQuestionText.)
Siebel VB Example
Dim Text as String Dim Orig as String Dim Lname as String Orig = Question.OriginalQuestionText Lname = Script.GetParameter ("PersonName") Text = SubstituteText (Orig, "PersonName", Lname) SetQuestionText Text
See Also
Page
Page returns the name of the current page.
Syntax
Page
Returns
The name of the page containing the question as a SmartScript Page.
Usage
Page is declared as type SmartScriptPage.
See Also
Script
Script returns the name of the script containing the question. It is declared as type SmartScript.
Syntax
Script
Returns
The name of the script containing the current question as a SmartScript.
Usage
Script is declared as a SmartScript.
SaveBusCompName
SaveBusCompName returns the name of the business component that stores the answer.
Syntax
SaveBusCompName
Returns
The name of the business component that stores the answer as a string.
Usage
This method returns the configured business component in which the answer is stored. This must be specified if a field is specified using SaveFieldName.
See Also
SaveBusObjName
SaveBusObjName returns the name of the business object that stores the answer.
Syntax
SaveBusObjName
Returns
The name of the business object in which the answer is to be stored as a string.
Usage
This function returns the configured business object that stores the answer. This must be specified if a business component and field are specified using SaveBusCompName and SaveFieldName, respectively. It is declared as a string.
See Also
SaveFieldName
SaveFieldName returns the name of the field that stores the answer.
Syntax
SaveFieldName
Returns
The name of the field that stores the answer as a string.
Usage
SaveFieldName returns the configured field name in which the answer value is stored. This may not be present for all questions, because not all questions store their answers in a field. (Some questions do not save answers.) It is declared as a string.
See Also
SetCurrentValue
SetCurrentValue is a procedure to set the value for the answer to a question.
Syntax
SetCurrentValue(value, [CurrencyCode, ExchangeDate])
Argument | Description |
---|---|
value |
The answer value to be given for the current question. |
CurrencyCode |
The currency code for the currency in which the answer is to be expressed if the question is a currency question. |
ExchangeDate |
The exchange date for the currency if the question is a currency question. |
Returns
Not applicable
Usage
The SetCurrentValue procedure sets the value for the question as if the user had entered it. All validation and branching are activated. If the question is a currency question (that is, the answer type is Currency), specify the currency code and exchange date in the function’s parameters. The currency code and exchange date parameters are optional.
If a question is to be saved to a business component field, do not use SetCurrentValue() for this question until after the SmartScript has been correctly positioned on that business component.
SetCurrentValue is declared as a string.
Siebel eScript Example
function Question_Enter (){ SetCurrentValue(“Hello"); }
See Also
SetQuestionEnable
SetQuestionEnable sets the enable state of the current question.
Syntax
SetQuestionEnable(Enabled)
Argument | Description |
---|---|
Enabled |
A Boolean value that enables (true) or disables (false) a question. |
Returns
Not applicable.
Usage
The SetQuestionEnable method sets the enable state of the current question. When the question is enabled, the user can modify the question's answer. If the question is disabled, the question's answer is read-only.
Siebel VB Example
SetQuestionEnable (false)
Siebel eScript Example
SetQuestionEnable (false);
SetQuestionText
SetQuestionText changes the displayed text for a question.
Syntax
SetQuestionText(text)
Argument | Description |
---|---|
text |
The new text to be substituted |
Returns
Not applicable
Usage
This procedure changes the displayed question text. Note that no automatic substitutions in the question text are supported.
Siebel VB Example
Dim City as String if City = "" then QuestionText = SubstituteText(QuestionText,"City", "[No City specified]") else QuestionText = SubstituteText(QuestionText,"City", City) Script.SetUserParameter "City", City end if SetQuestionText(QuestionText)
See Also
WasAnswered
WasAnswered returns a Boolean value indicating whether the question was answered.
Syntax
WasAnswered
Returns
TRUE if the user answered the question, or FALSE if not.
Usage
WasAnswered returns TRUE if the user answered this question or accepted a default answer and FALSE otherwise. The exceptions to this are Information questions and questions with an answer type of Boolean with no default answer; these questions return TRUE even if the agent merely passes through them.
WasAnswered is declared as type Boolean.
Improving the Performance of SmartScripts
You can improve the performance of your SmartScripts by setting the value of the business component user property, DeactivateBCField, to TRUE. This disables all business component fields except those used in SmartScript Questions. The default value for DeactivateBCField is FALSE.
To make this change in Siebel Tools, identify the SmartScript Player applet that the application uses, and change the user property for the business component on which this applet is based.
If you set DeactivateBCField to TRUE and you want to work with a field that is not in your SmartScript Question, you need to call ActivateField before you can work with the required field.
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(); }
Invoking Siebel Assignment Manager
You can invoke Siebel Assignment Manager from SmartScripts using Siebel eScript or Siebel VB. How you invoke Assignment Manager depends on the mode in which Assignment Manager is operating. If Assignment Manager is executing in interactive mode, you require a user (for example, a service representative) to perform some action (for example, assign a record to an employee) to advance the script.
If Assignment Manager is executing in dynamic mode, you can invoke it from a SmartScript by triggering certain events. A user is not required to invoke the Assignment Manager from the SmartScript.
The following example procedure demonstrates how to invoke Assignment Manager executing in dynamic mode on a newly created service request record.
To invoke Assignment Manager
Create assignment rules for the service request object.
For more information about assignment rules configuration, see Siebel Assignment Manager Administration Guide.
Create a SmartScript with values similar to those in the following table.
Element Attribute Value Question1
Name
SRDescription
Answer Type
String
Answer Control
Default
Save Business Object
Service Request
Save Business Component
Service Request
Save Field
Description
Translations
English-American
Question 2
Name
TestQuestion2
Answer Type
RDsr2
Answer Control
RDsr2
Translations
English-American
Page
Name
TestPage1
First Question
SRDescription
Translation
English-American
Label
TestPage1
Next Question
TestQuestion2
SmartScript
Name
SmartScript_AssignSR
Type
Pick any value (Other)
Active
Yes
First Page
TestPage1
Translation
English-American
Label
SmartScript Assign SR
Navigate to Administration - SmartScripts screen > Scripts view > Programs subview.
In the Programs list, select Script_Finish, and add the following code:
Note: When assigning an object, it must exist in order to match the assignment rules, criteria, and so on. To make sure that a newly created record exists in the database, users can run the following event:BusinessComponent.WriteRecord()
before calling an Assignment Manager method in the SmartScript event.function Script_Finish() { var sFirstQuestion = StartQuestion(); var SaveBC = sFirstQuestion.GetSaveBusComp(); TheApplication().Trace(" \n the value of sFirstQuestion = "+sFirstQuestion); SaveBC.ActivateField("Area"); SaveBC.SetFieldValue("Area", "Upgrade"); //***************** var myid = SaveBC.GetFieldValue("Id"); SaveBC.WriteRecord(); var bsAmgr = TheApplication().GetService("Synchronous Assignment Manager Requests"); var psInput = TheApplication().NewPropertySet(); var psOutput= TheApplication().NewPropertySet(); psInput.SetProperty("AsgnObjName","Service Request"); //Assignment Object Name psInput.SetProperty("ObjRowId", myid); //Object Row ID bsAmgr.InvokeMethod("Assign", psInput, psOutput); //***************** }
Siebel VB and Siebel eScript Sample Code
The three samples in this section are designed to work as a unit but are separated for simplicity. The samples are:
Sample Code of Dynamic Questions
The following sample code implements inserting an answer into a question dynamically. Specifically, it inserts the caller’s title and last name, as determined by previous questions, into the target question. The question might be entered into SmartScript as follows:
Hello. Is this [Contact.M/M] [Contact.LastName]?
Sample VB Code
Sub Question_Enter Dim MM as String Dim LastName as String Dim Q as SmartScriptQuestion Dim Text as String Set Q = Page.GetQuestion ("Contact: Mr/Ms") MM = Q.GetCurrentValue Set Q = Page.GetQuestion ("Contact: Last Name") LastName = Q.GetCurrentValue Text = OriginalQuestionText Text = SubstituteText (Text, "Contact.M/M", MM) Text = SubstituteText (Text, "Contact.Last Name", LastName) SetQuestionText (Text) End Sub
Sample eScript Code
function Question_Enter () { var MM; var LastName; var Q; var Text; Q = Page.GetQuestion ("Contact: Mr/Ms"); MM = Q.GetCurrentValue (); Q = Page.GetQuestion ("Contact: Last Name"); LastName = Q.GetCurrentValue (); Text = OriginalQuestionText (); Text = SubstituteText (Text, "Contact.M/M", MM); Text = SubstituteText (Text, "Contact.Last Name", LastName); SetQuestionText (Text); }
Sample Code of Finding a Contact
The following Siebel VB and Siebel eScript code samples look for the current caller in the database.
Sample VB Code
Sub Script_Open Dim FirstQuestion as SmartScriptQuestion Dim ContactBC as BusComp Dim ContactId as String Dim ContactExists as Integer Set FirstQuestion = StartQuestion Set ContactBC = FirstQuestion.GetSaveBusComp ContactBC.ActivateField "Id " ContactId = GetParameter("ContactId") If ContactId <> "" then ContactBC.SetViewMode 3 ContactBC.SetSearchSpec "Id", ContactId ContactBC.ExecuteQuery ForwardBackward ContactExists = ContactBC.FirstRecord() If not ContactExists then ContactBC.NewRecord NewBefore end if else ContactBC.NewRecord NewBefore end if End Sub
Sample eScript Code
function Script_Open () { var FirstQuestion; var ContactBC; var ContactId; var ContactExists; FirstQuestion = StartQuestion (); ContactBC = FirstQuestion.GetSaveBusComp (); ContactBC.ActivateField ("Id"); ContactId = GetParameter ("ContactId"); if (ContactId != "") { ContactBC.SetViewMode (3); ContactBC.SetSearchSpec ("Id", ContactId); ContactBC.ExecuteQuery (ForwardBackward); ContactExists = ContactBC.FirstRecord (); if (!ContactExists) { ContactBC.NewRecord (NewBefore); } } else { ContactBC.NewRecord (NewBefore); } }
Sample Code of Complex Branching
The following sample code demonstrates complex branching, setting branching activity (and the answer to a question), based on whether a contact existed or a new one was created. For sample code that demonstrates data acquisition and database querying, see Sample Code of Finding a Contact.
Sample VB Code
Function Question_PreBranch (Answer As String) As Integer Dim ContactBC as BusComp Dim ContactExists as Integer ContactBC = GetSaveBusComp ContactExists = ContactBC.FirstRecord() if ContactExists then Answer = “Y" else Answer = “N" end if Question_PreBranch = ContinueOperation End Sub
Sample eScript Code
function Question_PreBranch (&Answer) { var ContactBC; var ContactExists; ContactBC = GetSaveBusComp (); ContactExists = ContactBC.FirstRecord (); if (ContactExists) { Answer = "Y"; } else { Answer = "N"; } return (ContinueOperation);
Sample VB Code
Function Question_PreLeave() As Integer Script.Finish TheApplication.InvokeMethod "RunSmartScript", “Voicemail Script", "", "ENU", "USD" Question_PreLeave = ContinueOperation End Function
Sample eScript Code
function Question_PreLeave () { Script().Finish (); TheApplication().InvokeMethod ("RunSmartScript", "Voicemail Script", "", "ENU", "USD") return (ContinueOperation); }