Professional Documents
Culture Documents
Learning Objectives
After completing this module you will be able to: Describe Siebel Scripting capabilities and integration options as they relate to business requirements Describe how and where Siebel Scripting fits into the Siebel Web Architecture Identify installation and setup considerations Follow configuration steps for setting up Siebel Scripting Perform system administration tasks required for scripts to function Address implementation considerations and incorporate Best Practices
extending Siebel eBusiness Applications, where use of available declarative alternatives is either not practical or possible to achieve a business requirement.
Common usage scenarios might include Simple or complex customer specific data validation rules, based upon data internal or external to Siebel Communication with external sources, via Workflow processes Business Services and Transport Adapters (EAI) Virtual Business Components (VBCs) Dynamic user interaction with the user
Siebel 7 Scripting
The distinction between server and browser side scripts
Server scripts are written in Siebel VB or eScript Authored in Siebel Tools, or through the client in respects to writing client side Business Services Can use different languages at an object level within the repository Execute within the Application Object Manager (OM) On the Siebel Server for Web Clients, and on the client machine for Mobile or Dedicated Web Clients Offer limited support for user interaction Browser scripts are written in Javascript Authored within Siebel Tools Offers interfaces to Siebel objects in High Interactivity (HI) mode, and access to the DOM (Document Object Model) objects in Standard Interactivity (SI) mode Browser scripts are downloaded to the client, to execute within the framework of the browser.
Architecture
Architecture
Client Side
Web Client Desktop Apps
Web Server
SWE
External Applications
Siebel Database
10
Architecture
Server Side Layer Scripts Object Manager Applet BusComp Business Service Application Siebel VB eScript Client Side Web Browser Applet and controls Buscomp Business Service Application Javascript
Language
11
Architecture
Supported Platforms for scripting languages Language Siebel Visual Basic (VB) eScript Javascript Platform Windows only Windows Unix MS Internet Explorer 5.5+ Mozilla Firefox (for SI mode apps only)
12
Architecture
eScript and Siebel Visual Basic
This training course is not intended to teach these programming languages. It is left to the engineer to perform self study to become familiar with the functionality and syntax of these programming languages. For more information refer to the following bookshelf references:
Siebel eScript Language Reference Guide Siebel VB Language Reference Guide
13
Architecture
Events
The Siebel Scripting model is event driven model. Custom scripts implemented on objects in the Siebel repository can be triggered by various events Triggering events can occur when a user performs an action such as creating a new record, clicking an applet button or the user navigating to a new view.
Methods
In addition to supporting the placement of custom scripts on objects, they also support a range of standard methods that can be programmatically invoked from custom script. For example it is possible to programmatically search for records in the database, perform updates to the current record from a custom script or programmatically invoke a business service.
14
Architecture
The standard events and methods supported by Siebel scripting
objects maybe be different depending on whether you are scripting on browser or server side.
15
Architecture
Accessing Siebel Data from External Applications
In addition to implementing custom script on objects within the Siebel repository to modify the standard application behaviour to meet a customers requirement. A customer may also want to access Siebel data from a external application. It is possible to access Siebel data from an external MS Windows application written in either VB or C++ using the COM Data Server activex object.
See Siebel Object Interfaces Reference > COM Data Server Quick Reference
It is possible to access Siebel data from an external java application use the Java Data bean
See Siebel Object Interfaces Reference > Java Data Bean Quick Reference
16
Architecture
Controlling the Siebel Application from an external application
In some cases a customer may have a bespoke desktop application that they want to interact together with a current session of the Siebel application that might be running on the same PC. This is possible using the functionality provided by the automation server components which allows an application written in VB or C++ to programmatically interact with the current Siebel session running on the same PC. There are two versions of the automation server depending on whether the Siebel application will be run using the mobile web client or web client. See following references for supported methods:
Siebel Object Interfaces Reference > Mobile Web Client Automation Server Quick Reference Siebel Object Interfaces Reference > Siebel Web Client Automation Server Quick Reference
17
Server Scripting
18
Server Scripting
Server Scripts run in the Object Manager Mobile Web Clients execute server scripts locally
scripts are executed on the device. Instead the server scripts are executed at device synchronization time in a Siebel handheld deployment. Special consideration might need to be taken for this when implementing custom scripts.
19
Server Scripting
Server Scripts are written in eScript and/or SVB Specify language for each object in the repository (or
20
Server Scripting
Server Scripts are implemented in the repository
the select the object in the object explorer and right click to display popup menu.
Select Edit Server Scripts
menu option.
21
Server Scripting
When invoking the server script editor for the first time you will be asked which language that you want to
Use checkbox to set default language to be used for all objects. This can also be set default language in
Tools > View > Options > Scripting dialog. This setting is stored in tools.cfg file not in the Siebel repository.
22
Server Scripting
Custom server scripts can be placed on following objects
23
In Siebel 7.8 the Application object has the following scripting events in which you can place custom server scripts:
24
In Siebel 7.8 the Business Component object has the following scripting events in which you can place custom server scripts:
BusComp_PreNewRecord BusComp_PreQuery BusComp_NewRecord BusComp_Query BusComp_PreCopyRecord BusComp_PreInvokeMethod BusComp_CopyRecord BusComp_InvokeMethod BusComp_PreDeleteRecord BusComp_DeleteMethod BusComp_ChangeRecord BusComp_PreAssociateRecord BusComp_PreWriteRecord BusComp_AssociateRecord BusComp_WriteRecord BusComp_PreSetFieldValue BusComp_SetFieldValue BusComp_PreGetFieldValue
25
In siebel 7.8 the Applet object has the following scripting events in which you can place custom server scripts:
26
7.7.2.3 7.8.2.0
ST Engine ST Engine
27
memory footprint in cases where customers have implemented a significant amount of script. This will result in improved performance and lower garbage collection cost on heavily scripted events.
Improved scalability:
Added support for ECMAScript Edition 4 compliant strong typing. Using strongly typed objects results in more functional scripts and faster performance.
28
In the Siebel Tools and ALL client .cfg files, the EnableCLIScripting parameter must be added to the [Siebel] section, as follows:
[Siebel] RepositoryFile ApplicationName ApplicationTitle ApplicationSplashText Vertical ComponentName DataSource EnableCLIScripting
= siebel.srf = Siebel Tools = Siebel Tools = Tools = = Siebel Tools Client = Local = TRUE
29
30
31
32
The compiler can generate warnings for many problems that can otherwise cause runtime exceptions, such as incorrect method names, variables that are be used before being assigned, and incorrect conversions.
Deduce Types is a compiler option for deducing the types of
local variables. The compiler is capable of deducing the types of local variables by inspecting the assignments made to them, whenever such a deduction can be made. This allows the compiler to treat many of your typeless scripts as typed and you can enjoy the performance benefits and compilation warnings.
33
34
35
36
Browser Scripting
37
38
Object Model (DOM). That is, dependent on security settings on the client machine, they are able to access
DOM objects Desktop applications running on the client machine Local file systems
39
HI mode: Applet_PreInvokeMethod Applet_InvokeMethod Applet_ChangeRecord Applet_ChangeFieldValue Applet_Load BusComp_PreSetFieldValue Service_PreInvokeMethod Service_InvokeMethod Service_PreCanInvokeMethod
40
SI mode: Form Applet Control and List Applet List Column controls onmouseover onmouseout onblur onfocus onclick
41
Bookshelf 7.8 > Siebel Object Interfaces Reference > Browser Scripting > Supported DOM Events for High Interactivity Mode > Table 67
42
applets, and so on.) cannot be accessed from DOM events, in a supported manner. Usually in scripting you can call routines in the General section from anywhere in the object. However you cannot call routines written in the General section from the DOM events, in a supported manner. To associate a script with the control_OnClick event you need to use the Applet_PreInvokeMethod event associated with the applet.
43
44
Bookshelf 7.8 > Siebel Object Interfaces Reference > Browser Scripting > Supported DOM Events for Standard Interactivity Mode > Table 68
45
46
47
48
49
Flow of Execution
50
51
52
Where TEST is the method defined against the buttons Method Invoked property.
53
WebApplet_PreCanInvokeMethod
54
Value: 'INVOKE',
55
Value: 'INVOKE',
56
CancelOperation
Server Browser
DONE
57
Demo to show examples of flow of execution and use of ContinueOperation and CancelOperation
58
Business Services
59
use of some set of functionality. Objects that operate, or act upon, other objects to achieve a particular goal. Are not specifically tied to data or tables within the Siebel data model. Can simplify the task of moving data and converting data formats between the Siebel application and external applications. They can be assessed either directly by way of Workflows (Business Processes), or by way of script written against object(s) within the Repository. General business services are based on the class CSSService, although exceptions for specialised cases also exist.
60
application object(s):
Functionality documented in Bookshelf - invocation supported.
e.g. Workflow Process Manager BS used to invoke a Workflow Process.
Custom: Customer defined business processing defined in: Siebel Tools Web Client Business Service Administration
61
In Siebel Tools:
Created at design time in Siebel Tools using Siebel VB or Siebel eScript. Have to be compiled into SRF before testing possible. Stored in the repository and automatically migrated to new repository during the upgrade processes.
62
CancelOperation
CancelOperation
No Server Side processing if handled on browser side
Service_InvokeMethod
Server Browser
Service_InvokeMethod
DONE
63
ClientBusinessService1 = xxx Alert 613: Registering Business Services Called from Browser Script in Siebel Applications
Return CancelOperation in Service_PreInvokeMethod event to stop
64
Only server side events are invoked. No need to declare custom BS in [SWE] section of
CFG.
Return CancelOperation in Service_PreInvokeMethod event to
65
var psInput = theApplication().NewPropertySet(); var oService = theApplication().GetService(xxx); var psOutput = oService.InvokeMethod(xxx, psInput);
Server
var psInput = TheApplication().NewPropertySet(); var psOutput = TheApplication().NewPropertySet(); var oService = TheApplication().GetService(xxx); oService.InvokeMethod(xxx, psInput, psOutput);
66
67
customize your Siebel applications. However, adding scripting to Siebel applications increases the overall complexity of application maintenance and upgrades, thereby increasing the total cost of ownership. Poorly designed and implemented eScript or Siebel VB can directly and negatively impact the performance, scalability, and system stability of your Siebel application implementation. Primary references: Technical Note 514: Siebel Scripting Best Practices Bookshelf: Performance Tuning Guide > Tuning Customer Configurations for Performance > Best Practices for Siebel Scripting
68
Before resorting to using scripting you should always consider if there is a configuration based method of achieving the requirement. This is because a scripting solution may not be most effective or give best performance. See: Technical Note 591: Declarative Alternatives to Using Siebel Scripting Performance Tuning Guide > Tuning Customer Configurations for Performance > Best Practices for Siebel Scripting > Using Declarative Alternatives to Siebel Scripting OU Online Training Course: Declarative Alternatives to Siebel Scripting (7, Technical)
69
Implement exception handling code to handle unexpected errors in a controlled way and also perform clean up actions. In eScript and JavaScript use try-catch-finally statement
try { // code that should be executed goes here } catch (e) { // error handling code goes here for example TheApplication().RaiseErrorText(e.toString()); } finally { // clean up code that will be executed even if error occurs goes here }
In SVB use On Error Goto statement to run a block of exception handling code and actively check error codes returned by methods. See future Brownbag session on Exception Handling
70
71
eScript:
var fp=Clib.fopen(C:\\debug.txt,at); Clib.fputs( \n,fp); Clib.fclose(fp);
Siebel VB:
Open D:\debug.txt For Append As 1 write #1, query expression = & x Close #1
72
73
74
testing changes on the Siebel Developer Web Client without having to recompile SRF
1. Compile script once 2. Open client through Tools debugger environment and test script 3. Modify script 4. Save changes in Tools script editor 5. Test altered code on client 6. Save and compile final version of script before exiting Tools, in order for changes to persist in non-debug client.
Repeat steps 3-5 as required before final recompile of SRF
75
APPENDIX A
Server Side Scriptable Object Events
(See also Bookshelf > Siebel Object Interfaces Reference Guide)
76
Application Object
77
The Start event is called when the client starts and again when the user interface is first displayed. The argument commandline is passed to the event. It contains the text of the command line with which the Siebel application was started. You can place code that you want to run when the users application session is started in this event, for example to initialize profile attributes or start a business process.
78
The Close event is called before the application exits. This allows scripts to perform last-minute cleanup (such as cleaning up a connection to a COM server). It is called when Windows notifies the application that it should close (for example the user closes the browser window) , but not if the process is terminated directly.
79
It is possible to implement custom methods at the application level in this server scripting event. The PreInvokeMethod event is called before a specialized method is invoked by a user-defined applet menu or by calling InvokeMethod on the application. The argument methodName is passed to the event. It will contains the name of the method being invoked. Note that arguments are different to the browser scripting version of this event. There is not input property set for the server event.
80
The InvokeMethod event is called just after a specialized or user-defined method is invoked on the application. The argument methodName is passed to the event. It will contains the name of the method that has just been successfully invoked.
81
The PreNavigate event is called before the client navigates to a view. This event could be invoked as result of a user performing an action in the application (for example clicking a link or drilling down on a record) or even the execution of some script that navigates to a view. The arguments DestViewName and DestBusObjName are passed to the event. This identifies the name of the view to which the user is navigating and the business object of the destination view. This event can be used for validation and determining if the user should be allowed to navigate to the view. Return CancelOperation if the navigation should not proceed, else return ContinueOperation for the navigation to be allowed.
82
The Navigate event is called after the client has navigated to a view. Any code on this event will be executed if the PreNavigate event returned the value ContinueOperation. You could place code on this event for example to initialize data when a user navigates to a specific view.
83
84
The PreNewRecord event is called before a new row is created in the business component. The event will be triggered by the user performing action in the user interface to create a new record in an applet. It can also be triggered as result of custom code creating a new record in the buscomp. This event may be used to perform validation to determine if user is permitted to create a new record. Return CancelOperation if you do not want a new record to be created, otherwise returning ContinueOperation will allow a new record to be created (standard behavior).
85
The NewRecord event is called after a new row has been created in the business component, initialized due to configurations and made active. The event may be used to set up default values for fields. For example place code in this event to programmatically populate certain fields in the buscomp based on complex calculation. This event is not triggered if the new record has been created as the result of a copy operation either in the user interface or from custom script. The Buscomp_Copy event will be triggered instead.
86
The PreCopyRecord event is called before a new row is copied in the business component. The event may be used to perform pre-copy validation. Return CancelOperation to prevent the new record being created, or ContinueOperation to allow the record to be created and initialized.
87
The CopyRecord event is called after a row has been copied in the business component and has been made active. This event is called instead of BusComp_NewRecord when a new record is created:
through script with BusComp.NewRecord(NewAfterCopy or NewBeforeCopy) through any UI copy record mechanism (Edit > Copy Record; CTRL+B)
88
The PreDeleteRecord event is called before a row is deleted in the business component. This event may be used to perform validation checking to evaluate if the deletion should proceed. In this event you can evaluate the current value of fields within the record to be deleted using this.GetFieldValue(fieldname) To prevent the record from being deleted return CancelOperation, otherwise return ContinueOperation to allow the record to be deleted. TheApplication.RaiseErrorText(You are not allowed to delete this record) in this event will also prevent the record from being deleted (returns CancelOperation) whilst also displaying an error message to the user.
89
The DeleteRecord event is called after a row is deleted. The current context is a different row (the Fields of the just-deleted row are no longer available). When a user reads and deletes an existing record or creates and then undoes the new record, this invokes the DeleteRecord method and will results in the execution of any scripts on the PreDeleteRecord and DeleteRecord events.
90
The PreWriteRecord event is called before a new or updated row is written to the database. In this event you perform any final validation necessary before the actual save occurs. Return CancelOperation if you do not want the record to be written to the database, otherwise return ContinueOperation to allow the database to be updated. The PreWriteRecord event triggers only if a field value was modified or inserted, or when a record is deleted. When a record is deleted, PreWriteRecord is called to delete the implied join records to the initial record.
91
92
The WriteRecord event is called after a row is written out to the database. The WriteRecord event triggers after the record has been committed to the database. Do not use SetFieldValue in a WriteRecord event. If you need to use SetFieldValue, put it a PreWriteRecord event.
93
The PreSetFieldValue event is triggered when a field has been updated by the user in an applet or by code that invokes the SetFieldValue buscomp method to change a fields value. The argument FieldName is a string containing the name of the changed field. The argument FieldValue is a string containing the changed value. It is possible to implement code on this event to perform validation and or maybe perform a calculation based on the new field value. Return CancelOperation if you want to reject the new value and force the user to re-enter a new value, invoking the RaiseErrorText application method will also reject the value. To trigger this event as soon as user enters a value into a field set the fields property ImmediatePostChanges = True else the event will be triggered for all fields when the record is written.
94
The SetFieldValue event is triggered when a field has been sucessfully updated by the user in an applet or by code that invokes the SetFieldValue buscomp method to change a fields value. It will be triggered if any corresponding code on the PreSetFieldValue event returns the value ContinueOperation. The argument FieldName is a string containing the name of the changed field. This event is not triggered for any predefaulted or calculated fields in Siebel Tools.
95
The PreGetFieldValue event is called when the value of a business component field is accessed. This occurs when and applet needs to display data to the user or when custom code utilizes the GetFieldValue method. You can use this event to implement fields that are based on a complex calculation that needs to be implemented in code. The argument FieldName is a string containing the name of the field being accessed . Populate the argument FieldValue using your custom code with the desired value and return CancelOperation from the event.
Note: in eScript the & preceeding the FieldValue argument name indicates that the parameter is being passed to the event method by reference (and not value)
96
The PreQuery event is called before a query is executed against the database to populate the buscomp with data. This event may be used to perform validation and also modify the search criteria or to restrict the execution of certain queries.
Use this.GetSearchSpec() or this.GetSearchExpr() buscomp methods to get current search specification that will be used for the query. Use SetSearchSpec() or SetSearchExpr() buscomp methods to modify the search spec. Return CancelOperation if your want to prevent the query from being executed against the database.
97
The Query event is called just after the query is complete and the data haw been retrieved, but before the data is actually displayed in the UI. You could place code on this event to perform check on the data retrieved by the query. For example to display a popup message to the user if the query returned any data with a certain status.
98
The PreInvokeMethod event is called before any specialized or custom methods are invoked on the business component. It is possible to implement custom methods at buscomp level to perform certain business requirements. Argument methodName is a string containing the name of the method invoked. There is no input property set. Custom methods at buscomp level usual refer to field values within the current records context: for example this.GetFieldValue(fieldname) Return CancelOperation at the end of a custom method. Returning ContinueOperation allows a standard specialized class method to be executed.
99
The ChangeRecord event is called after a record becomes the current row in the business component. Code in the ChangeRecord event handler is executed each time that the focus changes to another record for example when user scrolls or clicks on a row of a list applet. Avoid lengthy operations in this event handler to enable smooth scrolling in list applets.
100
The PreAssociate event is called before a record is added to a business component to create an association. The semantics are the same as for BusComp_PreNewRecord. This event is applicable to buscomps in a many to many relationship. It is triggered on the child buscomp of the relationship.
101
The PreAssociate event is called before a record is added to a business component to create an association. The semantics are the same as for BusComp_PreNewRecord. This event is applicable to buscomps in a many to many relationship. You can implement code on this event to perform validation check to see if the association should proceed. Return CancelOperation to prevent the association or RaiseErrorText().
102
Applet Object
103
The PreInvokeMethod event is called before a specialized method for the applet is invoked or a user-defined method is invoked through from code using the InvokeMethod applet method. Argument methodName is a string variable containing the name of the method being invoked. To implement a custom method for the applet place custom code in this event. Return CancelOperation at the end of the custom methods implementation. Place code in this event to override or supplement standard functionality of an applet. Return CancelOperation in this event to prevent a specialized method to be executed. Return ContinueOperation in this event to allow standard or specialized methods to proceed.
104
The PreInvokeMethod event is called after a method has been sucessfully invoked against the applet. Argument methodName is a string variable containing the name of the method that was invoked. You could implement custom code here if you wanted implement additional application behaviour to occur after a standard or specialized method has completed execution.
105
The PreCanInvokeMethod event is called before the PreInvokeMethod and also when an applet is loaded, allowing the script to determine whether or not the user has the authority to invoke the Applet method. Argument methodName is a string variable containing the name of the method that was invoked. Argument &CanInvoke is a string representing whether or not the Applet method can be invoked. Valid values are TRUE or FALSE. This event determines if a button that invokes the method will be enabled in the user interface. Custom code in this event should populate the CanInvoke variable with the value TRUE in order for the button to be enabled. Return CancelOperation at the end of your custom code.
106
Example (eScript)
function WebApplet_PreCanInvokeMethod (MethodName, &CanInvoke) { if (MethodName == "CustomMethod") { CanInvoke = "TRUE"; return(CancelOperation); } return (ContinueOperation); }
107
The Load event is triggered just after an applet is loaded by the SWE. This event triggers for each applet on a view when the application or user triggers navigation to a new view. You can implement code on this event to perform initialization code, for example to programmatically set the search specification for a pick applet.
108
This event allows scripts to modify the HTML automatically generated by the Siebel Web Engine to render a control for an applet running in standard interactivity mode.
Argument controlName is a string indicating the name of the control to be rendered. Argument property is a string indicating the value of the property attribute of the swe:control or swe:this tag that triggers this event; it can also be an empty string if this attribute is not specified for the tag. Argument mode is a string indicating the mode of the applet that is currenlty being shown; possible modes are: Base, Edit, New, Query, Sort Argument &HTML is a string containing the HTML generated by the Siebel Web Engine for the control.
109
Custom code in this event can modify or replace the HTML code generated by the SWE The custom code needs to populate the argument HTML with the desired HTML code that represents the control. The WebApplet_ShowControl event is supported on SI mode applets only. See future Brownbag session covering ShowControl event for more detail regarding usage.
110
Example
This Siebel eScript script displays negative amounts in red in a read-only form.
function WebApplet_ShowControl (ControlName, Property, Mode, &HTML) { if( ControlName == "Amount" && Mode == "Base" && Property == "FormattedHTML") { var bc = this.BusComp(); var amount = ToNumber(bc.GetFieldValue("Transaction Amount")); if (amount < 0) HTML = "<FONT Color=Red> " + HTML + " </FONT>"; } }
111
This event allows scripts to modify the HTML automatically generated by the Siebel Web Engine to render a list column on an applet running in standard interactivity mode.
Argument controlName is a string indicating the name of the list column to be rendered. Argument property is a string indicating the value of the property attribute of the swe:control or swe:this tag that triggers this event; it can also be an empty string if this attribute is not specified for the tag. Argument mode is a string indicating the mode of the applet that is currenlty being shown; possible modes are: Base, Edit, New, Query, Sort Argument &HTML is a string containing the HTML generated by the Siebel Web Engine for the list column.
112
Custom code in this event can modify or replace the HTML code generated by the SWE The custom code needs to populate the argument HTML with the desired HTML code that represents the control. The WebApplet_ShowListColumn event is supported for applets running in SI mode only. See Brown bag session covering ShowListColumn event for more detail regarding usage.
113
Example
This Siebel eScript script displays the amounts in a list column in red.
function WebApplet_ShowListColumn (ColumnName, Property, Mode, &HTML) { if ((ColumnName == 'Amount') && (Mode == "Base") && (Property == "FormattedHTML")) { HTML = "<FONT Color=Red> " + HTML + " </FONT>"; } }
114