+ All Categories
Home > Documents > ripting With Siebel

ripting With Siebel

Date post: 03-Apr-2018
Category:
Upload: fayaz-syed
View: 221 times
Download: 0 times
Share this document with a friend

of 69

Transcript
  • 7/29/2019 ripting With Siebel

    1/69

    Scripting with Siebel

  • 7/29/2019 ripting With Siebel

    2/69

    Prerequisites Developers/Configurators are

    familiar with Siebel tools and Web

    Client Application. Knowledge of Java Scripts and

    Programming Languages like C

  • 7/29/2019 ripting With Siebel

    3/69

    What is ScriptingA sequence of statements executed at aParticular Event or when called explicitly.

    Advantages:

    The Siebel Script let you extend data validationbeyond what is already provided for in thestandard Siebel application.

    The Siebel Script provides data manipulation

    capabilities. (Inserting record, deleting record orupdating the record)

  • 7/29/2019 ripting With Siebel

    4/69

    When should be implemented

    Use scripting when you cannot implementthe desired functionality by

    Validation

    Pre and Post Default Values

    Required

    Read Only

  • 7/29/2019 ripting With Siebel

    5/69

    Alternatives for

    Scripting

    Do not write script if there is a way to

    implement the required functionality throughconfiguration. Declarative configuration iseasier to maintain and upgrade, leading to alower total cost of ownership.

  • 7/29/2019 ripting With Siebel

    6/69

    Field validation

    User properties

    Workflow

    Personalization

    Run-time eventsState model

  • 7/29/2019 ripting With Siebel

    7/69

    Replace Script with DeclarativeAlternatives

    For many functional requirements there is a configurationtechnique available that requires no script.

    Knowing these configuration techniques, one can makebetter decisions about whether to write script in the firstplace.

  • 7/29/2019 ripting With Siebel

    8/69

    Example: Field Data Validation

    Requirement: Field Validation

    if (fieldname == Activation Date){

    if(this.GetFieldValue(Expiration Date) != ){

    if(this.GetFieldValue(Activation Date) > this.GetFieldValue(ExpirationDate)){

    throw(Activation Date must be less than Expiration Date, ifExpiration Date has been filled in);}

    }}

  • 7/29/2019 ripting With Siebel

    9/69

    Configuration Alternative

    Solution: use BC Field Validation Property

  • 7/29/2019 ripting With Siebel

    10/69

    Configuration Alternative

    Additional properties introduced in Release 8.0 Validation Message with Symbolic String support

    Message Display Mode

  • 7/29/2019 ripting With Siebel

    11/69

    Example: Setting Field ValuesBased on Field Changes

    SetFieldValue eventif (fieldname == Product Serialized Flag){

    if(this.GetFieldValue(Serial Number) == && this.GetFieldValue(Product Serialized Flag) == Y){

    this.SetFieldValue(Serial Number,this.GetFieldValue(Asset Number));

    }}

  • 7/29/2019 ripting With Siebel

    12/69

    Configuration Alternative

    On Field Update Set User Property

  • 7/29/2019 ripting With Siebel

    13/69

    Other Siebel Alternatives to Script

    State Model

  • 7/29/2019 ripting With Siebel

    14/69

    Where is Script Written

    in Siebel Application Level Applet Level

    Business Component Level Business Services (Siebel Tools &

    Siebel Client)

  • 7/29/2019 ripting With Siebel

    15/69

    eScript Programming Basics

    Basic eScript Concepts Case,Comments, Identifiers,Variables, Blocks etc

    Data Types

    Operators

    Functions Expressions

    Statements

    Commands

    Object Handling

    Error Handling

  • 7/29/2019 ripting With Siebel

    16/69

    Data Types

    Data types in Siebel eScript can be classified into primitive

    types and object types.

    Primitive data type Aprimitive data typeis 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

    Chars

    Float

    Bool

    Undefined

    NOTE: When the chars, float, or bool primitive data typesare used to declare variables, they must be used as all lowercase.

  • 7/29/2019 ripting With Siebel

    17/69

    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 ofcharacters, and the second is a value that may be used in numericalcalculations.

  • 7/29/2019 ripting With Siebel

    18/69

    Boolean:-

    Siebel eScript implicitly converts values when appropriate, when aBoolean variable is used in a numeric context, its value is convertedto 0 if it is false, or 1 if it is true.

    Number

    A Number object is created by using the Numberconstructor in a newexpression

    ArrayAn array is a series of data stored in a variable

    NullThe null object is literally a null pointer. The null object type

    indicates that a variable is empty.

    var test = null;

  • 7/29/2019 ripting With Siebel

    19/69

    Expressions (Operators)

    Numeric Operators like +,-,\,MOD etc

    String Operators like &,+ used for string concatenation.

    Comparison Operators like ,=,,=

    Logical Operators like AND,OR,NOT etc

  • 7/29/2019 ripting With Siebel

    20/69

    Basic Arithmetic Operators in Siebel

  • 7/29/2019 ripting With Siebel

    21/69

    Basic Assignment Arithmetic Operators in

    Siebel

  • 7/29/2019 ripting With Siebel

    22/69

    Examples of assignment arithmetic:

    var i;

    i = 2; //i is now 2

    i += 3; //i is now 5 (2 + 3), same as i = i + 3

    i -= 3; //i is now 2 (5 - 3), same as i = i _ 3

    i *= 5; //i is now 10 (2 * 5), same as i = i * 5i /= 3; //i is now 3.333...(10 / 3); same as i = i / 3

    i = 10; //i is now 10

    i %= 3; //i is now 1, (10 mod 3), same as i = i % 3

  • 7/29/2019 ripting With Siebel

    23/69

    Logical Operators in Siebel eScript

  • 7/29/2019 ripting With Siebel

    24/69

    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

    b l P G d l

  • 7/29/2019 ripting With Siebel

    25/69

    Siebel eScript Programming Guidelines

    Declare your variables.

    Consider case sensitivity. Be aware that Siebel eScript iscase sensitive. Therefore, if you instantiate an object usingthe variable name SiebelApp, for example, eScript does notfind that object if the code references it as siebelapporSIEBELAPPinstead of SiebelApp. Case sensitivity alsoapplies to method names and other parts of Siebel eScript.

    Use parentheses () with functions. Siebel eScriptfunctions, like those in standard JavaScript, require trailingparentheses () even when they have no parameters.

  • 7/29/2019 ripting With Siebel

    26/69

    Use the thisobject reference. The special object reference thisiseScript shorthand for the current object. You should use thisin place ofreferences to active business objects and components. For example, in abusiness component event handler, you should use thisin place ofActiveBusComp, 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 constructdirects the program to choose among any number of alternatives yourequire, based on the value of a single variable. This alternative is greatly

    preferable to a series of nested If statements because it simplifies codemaintenance. It also improves performance, because the variable must beevaluated only once.

  • 7/29/2019 ripting With Siebel

    27/69

    Some eScript Concepts Case Sensitivity White-Space Characters

    Comments Variables

  • 7/29/2019 ripting With Siebel

    28/69

    Case Sensitivity Siebel eScript is case sensitive. A variable namedtestvar is a different variable than one namedTestVar, and both of them can exist in a script at

    the same time. Thus, the following code fragmentdefines two separate variables:

    var testvar = 5;

    var TestVar = 5;

  • 7/29/2019 ripting With Siebel

    29/69

    White Space Characters

    White space separates identifiers into separateentities. For example, ab is one variable name, anda b is two. Thus, the fragment

    var ab = 2 is valid, but

    var a b = 2 is not.

  • 7/29/2019 ripting With Siebel

    30/69

    Comments

    Comments that explain lines of code help users understand thepurpose and program flow of a program, making it easier to altercode.

    There are two formats for comments, end-of-line comments andblock comments.

    End-of-line comments begin with two slash characters, //. Anytext after two consecutive slash characters is ignored to the endof the current line. The Siebel eScript interpreter beginsinterpreting 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 thesemarkers is a comment, even if the comment extends over multiplelines. Block comments may not be nested within block comments,but end-of-line comments can exist within block comments.

  • 7/29/2019 ripting With Siebel

    31/69

    The following code fragments are examples of validcomments:

    // 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 butvar TestStr = "This line is not a comment.";

  • 7/29/2019 ripting With Siebel

    32/69

    Variables

    To declare a variable, use the var keyword. To make it local,declare it in a function.

    var perfectNumber;A value may be assigned to a variable when it is declared:

    var perfetNumber = 28;

  • 7/29/2019 ripting With Siebel

    33/69

    VariablesIn 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...}

  • 7/29/2019 ripting With Siebel

    34/69

    Web Architecture

  • 7/29/2019 ripting With Siebel

    35/69

    Types of Scripting

    Browser Scripting

    Server Scripting

  • 7/29/2019 ripting With Siebel

    36/69

    Server Script Architecture

  • 7/29/2019 ripting With Siebel

    37/69

    Browser Script Architecture

  • 7/29/2019 ripting With Siebel

    38/69

    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

  • 7/29/2019 ripting With Siebel

    39/69

    Browser Script Interpreted by IE Browser Java Script

    Server Script Interpreted by the ObjectManager

    Siebel Visual Basic (Visual Basic syntax) Siebel eScript (Java syntax).

    Browser & Server Script can be written Application Level Applet Level Business Component Level

    Business Services (Browser Script only Siebel Tools)

  • 7/29/2019 ripting With Siebel

    40/69

    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 beachieved by writing a server script.

    Written in Siebel VB (for Windows ) and Siebel eScript (for Windows orUNIX).

    e.g Business Component Script, Business Service Script, Application Script; andApplet Web Script.

    Server script use RaiseError, RaiseErrorText, and LookupMessage to pop upmessages.

  • 7/29/2019 ripting With Siebel

    41/69

    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 viaBrowser 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 Clientgenbscript ENU\uagent.cfg c:\sea703\client\PUBLIC\enu

    Siebel Servergenbscript ENU\siebel.cfg c:\sea703\siebsrvr\WEBMASTER ENU

    Refreshing the Web Server

    Once the genbscript utility has been run, the Siebel web server must berestarted.

  • 7/29/2019 ripting With Siebel

    42/69

    Using the Siebel Script Editor

  • 7/29/2019 ripting With Siebel

    43/69

    Adding Scripts to Event Handlers

    Enter the script betweenthe predefined beginning and end of the routine

    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

  • 7/29/2019 ripting With Siebel

    44/69

    Programming Statements

    Output Statements

    Input Statements

    Arithmetic Statements (Arithmetic Operators)

    String Manipulations Conditional Statements (Logical & Relational

    Operators)

    Loop Statements

    Database Related Statements

  • 7/29/2019 ripting With Siebel

    45/69

    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.

  • 7/29/2019 ripting With Siebel

    46/69

    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.

    d l

  • 7/29/2019 ripting With Siebel

    47/69

    Conditional Statements

    IF statement is commonly used keyword for any scripting language. IfCondition returns TRUE, the following statements will be executed.

    Browser Script (Uses Javascript)If (condition){.}

    Server Script (Uses eScript or Siebel VB) Siebel Visual Basic (it is got Visual Basic syntax)If (condition) then.End if

    eScript (it is got Java Syntax)If (condition){

    .}

    IF S t x

  • 7/29/2019 ripting With Siebel

    48/69

    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 thenTheApplication.RaiseErrorText A is equal to B

    End ifServer Script eScript: (Case sensitive)If (a==b)

    {TheApplication().RaiseErrorText (A is equal to B);

    }

    IF (C d )

  • 7/29/2019 ripting With Siebel

    49/69

    IF Syntax (Contd.) Browser Script - Javascript: (Case sensitive)

    if (a==b)alert(A is equal to B);

    elsealert (A is not equal to B);

    Server Script - Siebel Visual Basic: (Case insensitive)

    If a=b thenTheApplication.RaiseErrorText A is equal to B

    ElseTheApplication.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);

    N d If S

  • 7/29/2019 ripting With Siebel

    50/69

    Nested If Syntax Multiple IF conditions are allowed.

    If (A=B) then

    If (A=C) thenTheApplication.RaiseErrorText All values are equal

    ElseTheApplication.RaiseErrorText Only A and B are

    equal

    End If

    ElseTheApplication.RaiseErrorText A & B are not equal

    End If

    L St t ts

  • 7/29/2019 ripting With Siebel

    51/69

    Loop Statements

    While (Condition) Condition is checked before the

    statements are executed in the block

    Do.Loop (Condition) First time, all the statements in theblock are executed. Condition is checkedbefore getting into the loop.

    For variable = 1 to nNext variable Repeats the loop n times

  • 7/29/2019 ripting With Siebel

    52/69

    Database Statements

    Database Operations Query

    Insert Record Delete Record

    Field Update

    Associate child record to Parent RecordNote: Later Slides in the presentation will show how Siebel performs DB

    operations.

  • 7/29/2019 ripting With Siebel

    53/69

    Events - Triggering Point

    f E

  • 7/29/2019 ripting With Siebel

    54/69

    Object Interface Events

    The object interface events areavailable in Server Script or Browser

    Script within Siebel Tools. Application Events Applet Events

    Business Component Events

    Business Service Events

    L l t hi h S i ti i d

  • 7/29/2019 ripting With Siebel

    55/69

    Levels at which Scripting is done

    Application LevelApplet Level

    Business Component LevelBusiness Service Level

    Application Events & MethodsEvents like Application_Start

    Application_Close

    Methods like TheApplication.ActiveBusObject

    TheApplication.ActiveBusComp

    TheApplication.LoginName

    TheApplication.GotoView

    Applet Events & Methods

    Events like Applet_ChangeFieldValueApplet_ChangeRecordWebApplet_Load

    WebApplet_PreCanInvokeMethod 3

    Called before the PreInvokeMethod,determines whether ornot the user has the authority to invoke the Applet method.

    Applet_InvokeMethod

    M th d lik A l t B Obj t

  • 7/29/2019 ripting With Siebel

    56/69

    Methods like Applet.BusObject

    Applet.BusComp

    Applet.InvokeMethod

    Applet.Name

    Business Component Events & Methods

    Events like BusComp_ChangeRecordBusComp_DeleteRecordBusComp_WriteRecord

    BusComp_Query

    BusComp_InvokeMethod

    Methods like BusComp.ActivateField(FieldName)BusComp.ClearToQuery

    BusComp.ExecuteQueryBusComp.GetFieldValue

    BusComp.SetFieldValue

    BusComp.NewRecord

    BusComp.DeleteRecord

    Business Service Events & Methods

    Events like Service_InvokeMethodService_PreInvokeMethodService_PreCanInvokeMethod

    Methods like Service.GetProperty(propName)

    Service.SetProperty(propName, propValue)

    Ob H dl

  • 7/29/2019 ripting With Siebel

    57/69

    Object Handling

    Declare variable Get the Object handler Clear the query

    Activate the Field (activate fields which is requiredto 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.

    http://localhost/var/www/apps/conversion/tmp/scratch_14/ObjSyntax_t.htmlhttp://localhost/var/www/apps/conversion/tmp/scratch_14/ObjSyntax_t.htmlhttp://localhost/var/www/apps/conversion/tmp/scratch_14/ObjSyntax_t.html
  • 7/29/2019 ripting With Siebel

    58/69

    In eScript, destroy an object by setting it to null (oBC =null). In Siebel VB, destroy an object by setting it tonothing (Set oBC = Nothing).

    Release objects in the reverse order in which the Siebelapplication created them; child objects first, parentobjects second.

    Pick/Associate/MVG business components before the parentbusiness component

    Business components before business objects No specific order for property sets and business services

    since they are independently created from the application

  • 7/29/2019 ripting With Siebel

    59/69

    Place Code in the CorrectEvent Handler

    One of the most common issues identified during script reviews is theinappropriate use of object events. Placing code in the wrong eventHandler can lead to altered data and may negatively impactperformance.

    Do not use Siebel application Pre- events (such as PreQuery,PreSetFieldValue, and PreWriteRecord) to manipulate data inobjects other than the one hosting the script.

  • 7/29/2019 ripting With Siebel

    60/69

    The companion events, such as Query, SetFieldValue, andWriteRecord, occur after the internal and field-levelvalidations succeed, and therefore are the appropriateevents for such manipulation.

    For example, the WriteRecord event fires after the recordwrites successfully. When this event fires, you know thatthe record exists; therefore it is safe to create or modifydata in other objects, without fearing orphaned records oran inconsistent state of the application.

  • 7/29/2019 ripting With Siebel

    61/69

    BusComp_PreSetFieldValue : Field level validation

    BusComp_PreWriteRecord : Record level validation

    BusComp_SetFieldValue : Field triggered actions

    BusComp_WriteRecord : Record triggered actions

    Example: synchronizing two business components or creatingactivities

    BusComp_PreQuery :Code control over SearchSpecs

    Error Handling in eScript

  • 7/29/2019 ripting With Siebel

    62/69

    Error Handling in eScript

    Implement eScript error handling through the try/catch/finally mechanism.

    Try block: contains the logic that you want performed. Catch block: captures the error. Finally block: performs any cleanup work such as destroying object

    references.

    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 throwan exception.

  • 7/29/2019 ripting With Siebel

    63/69

    Practical - 1Creating Custom Buttons to Control User Navigation

    B tt A l t

  • 7/29/2019 ripting With Siebel

    64/69

    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.

    X denotes empty

    placeholders

    f h h d b

  • 7/29/2019 ripting With Siebel

    65/69

    Specify the Method to beInvoked

    Standard methods are:

    For Custom method, type the name of the method in

    Method Invoked Property of the button. Caption = Title Method Invoked = AcceptRecord Name = AcceptBtn

    Save the Applet and close the Wed Layout editor.

  • 7/29/2019 ripting With Siebel

    66/69

    Enable the button

    To enable a button theWebApplet_PreCanInvokeMethod eventmust be scripted to set its parameter

    to TRUE.

    Add S i t i B

  • 7/29/2019 ripting With Siebel

    67/69

    Add Script in BrowserScript

    Save the Applet and close the script editor.Note: Server methods can also be called instead of browser script.

    Place code in BusComp_PreInvokeMethod BC event

    or WebApplet_PreInvokeMethod event

    B l f ld

  • 7/29/2019 ripting With Siebel

    68/69

    Browser Script Compiler folder

    Used to specify the

    folder where

    bscripts\all resides.

    This is the folder

    where Browser Scripts

    are generated during

    compilation

    Syntax: Genbscriptj:\Siebel\7.7\web client\bin\enu\uagent.cfgj:\Siebel\7.7\webclient\public\enuENU

    Execute GenBScript to generate Browser Script

    if it is not generated during compilation

    Cli k h A l

  • 7/29/2019 ripting With Siebel

    69/69

    Click on the Applet

    Compile the Applet

    Execute the Siebel Web Client

    Navigate to the view where appletwas modified to hold the buttonwith title Accept.

    The Browser Script should displayan alert box indicating

    Hello ! I am in AcceptRecord "


Recommended