Escolar Documentos
Profissional Documentos
Cultura Documentos
Prerequisites
Developers/Configurators are familiar with Siebel tools and Web Client Application. Knowledge of Java Scripts and Programming Languages like C
What is Scripting
A sequence of statements executed at a Particular Event or when called explicitly.
Advantages: The Siebel Script let you extend data validation beyond what is already provided for in the standard Siebel application. The Siebel Script provides data manipulation capabilities. (Inserting record, deleting record or updating the record)
Field validation User properties Workflow Personalization Run-time events State model
Configuration Alternative
Solution: use BC Field Validation Property
Configuration Alternative
Additional properties introduced in Release 8.0
Validation Message with Symbolic String support Message Display Mode
Configuration Alternative
On Field Update Set User Property
State Model
Data Types
Data types in Siebel eScript can be classified into primitive types and object types.
A primitive data type is the set of all possible values of a primitive value. A variable that is of a primitive data type is simply a value. The Primitive Data Types are
NOTE: When the chars, float, or bool primitive data types are used to declare variables, they must be used as all lowercase.
Object type:Object types that are built into the scripting engine are: String:A string is written using a pair of either double or single quotation marks, for example: "I am a string" 'so am I' "344" The string "344" is different from the number 344. The first is an array of characters, and the second is a value that may be used in numerical calculations.
Boolean: Siebel eScript implicitly converts values when appropriate, when a Boolean variable is used in a numeric context, its value is converted to 0 if it is false, or 1 if it is true.
Number A Number object is created by using the Number constructor in a new expression
Array
An array is a series of data stored in a variable
Null
The null object is literally a null pointer. The null object type indicates that a variable is empty.
Expressions (Operators)
Numeric Operators String Operators Comparison Operators Logical Operators like +,-,\,MOD etc like &,+ used for string concatenation. like <,>,=,<>,<=,>= like AND,OR,NOT etc
Siebel eScript statements break Statement continue Statement do...while Statement for Statement for...in Statement goto Statement if Statement switch Statement throw Statement try Statement while Statement with Statement
Declare your variables. Consider case sensitivity. Be aware that Siebel eScript is case sensitive. Therefore, if you instantiate an object using the variable name SiebelApp, for example, eScript does not find that object if the code references it as siebelapp or SIEBELAPP instead of SiebelApp. Case sensitivity also applies to method names and other parts of Siebel eScript. Use parentheses () with functions. Siebel eScript functions, like those in standard JavaScript, require trailing parentheses () even when they have no parameters.
Use the this object reference. The special object reference this is eScript shorthand for the current object. You should use this in place of references to active business objects and components. For example, in a business component event handler, you should use this in place of ActiveBusComp, as shown in the following example:
function BusComp_PreQuery () { this.ActivateField("Account"); this.ActivateField("Account Location"); this.ClearToQuery(); this.SetSortSpec( "Account(DESCENDING)," + " Account Location(DESCENDING)"); this.ExecuteQuery(); return (ContinueOperation); }
Make effective use of the switch construct. The switch construct directs the program to choose among any number of alternatives you require, based on the value of a single variable. This alternative is greatly preferable to a series of nested If statements because it simplifies code maintenance. It also improves performance, because the variable must be evaluated only once.
Case Sensitivity
Siebel eScript is case sensitive. A variable named testvar is a different variable than one named TestVar, and both of them can exist in a script at the same time. Thus, the following code fragment defines two separate variables:
Comments
Comments that explain lines of code help users understand the purpose and program flow of a program, making it easier to alter code. There are two formats for comments, end-of-line comments and block comments. End-of-line comments begin with two slash characters, //. Any text after two consecutive slash characters is ignored to the end of the current line. The Siebel eScript interpreter begins interpreting text as code on the next line. Block comments are enclosed within a beginning block comment, /*, and an end of block comment, */. Any text between these markers is a comment, even if the comment extends over multiple lines. Block comments may not be nested within block comments, but end-of-line comments can exist within block comments.
// this is an end of line comment /* this is a block comment. This is one big comment block. // this comment is okay inside the block. The interpreter ignores it. */ var FavoriteAnimal = "dog"; // except for poodles //This line is a comment but var TestStr = "This line is not a comment.";
Variables
To declare a variable, use the var keyword. To make it local, declare it in a function. var perfectNumber;
Variables
In the following example, a is global to its object because it was declared outside of a function. Typically you declare all global variables in a general declarations section. The variables b, c, and d are local because they are defined within functions. var a = 1; function myFunction() { var b = 1; var d = 3; someFunction(d); } function someFunction(e) { var c = 2 ... }
Web Architecture
Types of Scripting
Browser Scripting Server Scripting
Browser script is recommended for: Communication with the user Interaction with desktop applications Data validation and manipulation limited to the current record
Server script is recommended for: Query, insert, update, and delete operations Access to data beyond the current record
Application Level Applet Level Business Component Level Business Services (Browser Script only Siebel Tools)
Server Scripts:
Server Script executes within the Object Manager so no direct UI interaction is possible. In some cases scripts have to use functionality that is available only on the server side, such as the methods GetBusObject, ExecuteQuery . This can be achieved by writing a server script. Written in Siebel VB (for Windows ) and Siebel eScript (for Windows or UNIX). e.g Business Component Script, Business Service Script, Application Script; and Applet Web Script. Server script use RaiseError, RaiseErrorText, and LookupMessage to pop up messages.
Browser Scripts:
Browser Script executes in and is interpreted by the Browser. If client need to implement functionality in the Browser, this should be done via Browser Script. Some functionalities are available only on the browser (for example, Applet_ChangeRecord Event).For this developer has to write Browser script. Browser Scripts are written in JavaScript. Browser script use Alerts to pop up message box on browser. To generate browser script The utility is called genbscript.exe and may be found in either siebsrvr/bin or client/bin.
For Mobile Client genbscript ENU\uagent.cfg c:\sea703\client\PUBLIC\enu
Siebel Server
genbscript ENU\siebel.cfg c:\sea703\siebsrvr\WEBMASTER ENU Refreshing the Web Server Once the genbscript utility has been run, the Siebel web server must be restarted.
Do not alter the Function, End Function, Sub or End Sub statements A function will return a value, a sub will not Some routines will have an argument list, some will not
Programming Statements
Output Statements Input Statements Arithmetic Statements (Arithmetic Operators) String Manipulations Conditional Statements (Logical & Relational Operators) Loop Statements Database Related Statements
Outputs Statements
A Message to convey to the end user Browser Script
Alert(message)
Server Script
TheApplication.RaiseErrorText Message
Note: RaiseErrorText will cancel the execution of subsequent statements. This should be used when there are no statements to be executed.
Input Statements
To get an Input value from the End-User Browser Script
Name = Prompt (Enter your name: )
Server Script None Note: Use Browser script to accept any input from the user and pass it to the server script.
Conditional Statements
IF statement is commonly used keyword for any scripting language. If Condition returns TRUE, the following statements will be executed. Browser Script (Uses Javascript)
If (condition) { . }
IF Syntax
Browser Script - Javascript: (Case sensitive) if (a==b) { alert(A is equal to B); } Server Script - Siebel Visual Basic: (Case insensitive) If a=b then TheApplication.RaiseErrorText A is equal to B End if Server Script eScript: (Case sensitive) If (a==b) { TheApplication().RaiseErrorText (A is equal to B); }
IF Syntax (Contd.)
Browser Script - Javascript: (Case sensitive) if (a==b) alert(A is equal to B); else alert (A is not equal to B); Server Script - Siebel Visual Basic: (Case insensitive) If a=b then TheApplication.RaiseErrorText A is equal to B Else TheApplication.RaiseErrorText A Is not equal to B End if Server Script eScript: (Case sensitive) If (a==b) TheApplication().RaiseErrorText (A is equal to B); else TheApplication().RaiseErrorText (A is not equal to B);
Nested If Syntax
Multiple IF conditions are allowed. If (A=B) then If (A=C) then
TheApplication.RaiseErrorText All values are equal
Else
equal
Loop Statements
While (Condition)
Condition is checked before the statements are executed in the block
Do.Loop (Condition)
First time, all the statements in the block are executed. Condition is checked before getting into the loop.
Database Statements
Database Operations
Query Insert Record Delete Record Field Update Associate child record to Parent Record
Note: Later Slides in the presentation will show how Siebel performs DB operations.
Methods like
Methods like
Methods like
Methods like
Object Handling
Declare variable Get the Object handler Clear the query Activate the Field (activate fields which is required to be used for processing) Set the Sort Spec (by default it is ASCENDING) Execute Query (ForwardOnly & ForwardBackward) Clear the object handler and release the memory.
In eScript, destroy an object by setting it to null (oBC = null). In Siebel VB, destroy an object by setting it to nothing (Set oBC = Nothing). Release objects in the reverse order in which the Siebel application created them; child objects first, parent objects second.
Pick/Associate/MVG business components before the parent business component Business components before business objects No specific order for property sets and business services since they are independently created from the application
The companion events, such as Query, SetFieldValue, and WriteRecord, occur after the internal and field-level validations succeed, and therefore are the appropriate events for such manipulation. For example, the WriteRecord event fires after the record writes successfully. When this event fires, you know that the record exists; therefore it is safe to create or modify data in other objects, without fearing orphaned records or an inconsistent state of the application.
BusComp_SetFieldValue
BusComp_WriteRecord activities
Example:
function illustrateErrorHandling() { try { /*The try block encompasses all statements that could cause an exception. */ ...executable code goes here... }//end try The try keyword precedes a block of normal processing code that may throw an exception.
Practical - 1
Creating Custom Buttons to Control User Navigation
Button on an Applet
Edit the Web Layout of the Applet Select the mode of the Applet (Base or Edit or Edit List) Drag & Drop the button from the Web Controls toolbar on the Applet where placeholder is available.
For Custom method, type the name of the method in Method Invoked Property of the button.
Caption = Title Method Invoked = AcceptRecord Name = AcceptBtn
Used to specify the folder where bscripts\all resides. This is the folder where Browser Scripts are generated during compilation
Compile the Applet Execute the Siebel Web Client Navigate to the view where applet was modified to hold the button with title Accept. The Browser Script should display an alert box indicating Hello ! I am in AcceptRecord "