Вы находитесь на странице: 1из 114

1

<Insert Picture Here>

Scripting For Siebel 7 (Technical)


Presented by: Richard Chadd
Richard Smith
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’

3
Siebel Scripting Training

• What Is Siebel Scripting? <Insert Picture Here>

• Architecture
• Server Script
• Browser Script
• Flow of Execution
• Business Services
• Implementation Considerations and Best Practices
• Testing and Debugging
• Appendix

4
<Insert Picture Here>

Siebel Scripting Overview

5
What is Siebel Scripting?

• A multilingual coding mechanism used to provide


extended functionality to an otherwise declaratively
configured Siebel application.
• Siebel 7 supports:
• The use of both Siebel VB and eScript for Object Manager
(server) side scripting.
• Javascript for client (browser) side scripting.

6
Siebel Scripting Capabilities

• Siebel Scripting provides a flexible mechanism for


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

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

8
<Insert Picture Here>

Architecture

9
Architecture
Client Side

Web Client Desktop Apps

Web Server
SWE

Siebel Server External


Server Side Applications
Object
Manager

Siebel
Database

10
Architecture

Server Side Client Side

Layer Object Manager Web Browser

Scripts Applet Applet and controls


BusComp Buscomp
Business Service Business Service
Application Application

Language Siebel VB Javascript


eScript

11
Architecture

Supported Platforms for scripting languages

Language Platform

Siebel Visual Basic (VB) Windows only

eScript Windows
Unix
Javascript 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


are documented in the Siebel Tools online help.

• Refer to the bookshelf reference:

• Siebel Object Interfaces Reference > Interfaces Reference

• It should be noted that the methods and events supported by


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
<Insert Picture Here>

Server Scripting

18
Server Scripting

• Server Scripts run in the Object Manager

• Mobile Web Clients execute server scripts locally


within the object manager of the Siebel.EXE process.

• With the Siebel Handheld applications no custom


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


specify default one in tools options)

• The choice of language might be dependent on OS


platform (Unix = eScript)

20
Server Scripting

• Server Scripts are implemented in the repository


using Siebel Tools.

• To Edit server scripts select


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 for the current repository object.

• 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


in the repository:

• Application
• Business Components
• Applets

• In addition it is possible to implement custom Business


Services using server scripting

23
Server Scripting – Application object
• In Siebel 7.8 the Application object has the following scripting
events in which you can place custom server scripts:

• Application_Start
• Application_Close
• Application_PreInvokeMethod
• Application_InvokeMethod
• Application_PreNavigate
• Application_Navigate

• See APPENDIX A for specific descriptions of these


events

24
Server Scripting – BusComp object
• 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

• See APPENDIX A for specific descriptions of these events

25
Server Scripting – Applet object
• In siebel 7.8 the Applet object has the following scripting
events in which you can place custom server scripts:

• WebApplet_PreInvokeMethod
• WebApplet_InvokeMethod
• WebApplet_PreCanInvokeMethod
• WebApplet_Load
• WebApplet_ShowControl
• WebApplet_ShowListControl

• See APPENDIX A for specific descriptions of these events

26
Server Scripting - eScript Engines

7.0.x : T Engine
7.5.x : T Engine
7.7.x : T Engine 7.7.2.3 ST Engine

7.8.x : T Engine 7.8.2.0 ST Engine

27
Benefits of ST Scripting Engine:

• Improved performance: Higher throughput with a lower CPU and


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:
Lower footprint per user for CPU and memory use

• New functionality:
Added support for ECMAScript Edition 4 compliant strong
typing. Using strongly typed objects results in more functional scripts
and faster performance.

28
Enabling ST Script Engine in > 7.7.2.3

• In the Siebel Tools and ALL client .cfg files, the


‘EnableCLIScripting’ parameter must be added to the [Siebel]
section, as follows:

[Siebel]
RepositoryFile = siebel.srf
ApplicationName = Siebel Tools
ApplicationTitle = Siebel Tools
ApplicationSplashText = Tools
Vertical =
ComponentName = Siebel Tools Client
DataSource = Local
EnableCLIScripting = TRUE

29
Enabling ST Script Engine in > 7.8.2

30
Server Scripting – Tools Options
T Script Engine ST Script Engine

31
Enable Method Listing / Enable Auto Complete

32
Enable Warnings / Deduce Types

• Enable Warnings is a compiler option to generate warnings.


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
ST Scripting Engine References

• Bookshelf:
• Using Siebel Tools > Siebel Script Editors > About the ST
eScript Engine

• SupportWeb:
• Technical Note 610: Scripting Enhancements in Siebel Fix
Pack 7.7.2.3

34
v8 Enhancements to ST Scripting Engine

35
v8 Enhancements – ‘Enable Favorites’
• Most frequently accessed objects exposed in the Script
Assist window appear at the top
• Favourites appear in italic type
• Session based
• Unused favourites eventually drop back down list

36
<Insert Picture Here>

Browser Scripting

37
What is Browser Script?

• JavaScript written to support:


• Siebel object events and the DOM for, generally, employee
facing applications (HI)

• DOM events only for customer facing applications (SI), for


example, ‘onblur’, ‘onfocus’,’onclick’,’onmouseover’,
‘onmouseout’

38
The Document Object Model (DOM)

• Browser scripts can access the browser’s Document


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
Supported Events for Browser scripting

• HI mode:
• Applet_PreInvokeMethod
• Applet_InvokeMethod
• Applet_ChangeRecord
• Applet_ChangeFieldValue
• Applet_Load
• BusComp_PreSetFieldValue
• Service_PreInvokeMethod
• Service_InvokeMethod
• Service_PreCanInvokeMethod

40
Supported Events for Browser scripting

• SI mode:
• Form Applet Control and List Applet List Column controls
• onmouseover
• onmouseout
• onblur
• onfocus
• onclick

41
Supported DOM Events for HI Mode

Bookshelf 7.8 > Siebel Object Interfaces Reference > Browser Scripting > Supported DOM Events for High Interactivity Mode > Table 67

42
Supported DOM Events for HI Mode (cont’d)

• NOTE: Siebel objects (business components,


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
Supported DOM Events for SI Mode

44
Supported DOM Events for SI Mode (cont’d)

Bookshelf 7.8 > Siebel Object Interfaces Reference > Browser Scripting > Supported DOM Events for Standard Interactivity Mode > Table 68

45
Generating Browser Scripts
• If Browser script compilation folder is set in Tools, those written against the compiled objects will be generated.
• View > Options > Scripting

46
Generating Browser Scripts (cont’d)

• ‘genbscript.exe’ utility should be used when wishing to


generate all browser scripts for a given SRF.
• Located in <…\client\BIN> or <…\SIEBSRVR\BIN> directories
• Run via command prompt
• Syntax: genbscript <config file> <destination directory> [language]

47
Generating Browser Scripts (cont’d)

• Dedicated Web Client:


C:\ses78\client\BIN\genbscript.exe
C:\ses78\client\BIN\ENU\uagent.cfg
C:\ses78\client\PUBLIC\enu

• Web Clients:
C:\ses78\SIEBSRVR\BIN\genbscript.exe
C:\ses78\SIEBSRVR\BIN\ENU\uagent.cfg
C:\ses75\SIEBSRVR\WEBMASTER

48
Generating Browser Scripts (cont’d)

• Bookshelf (7.8):
• Configuring Siebel eBusiness Applications > Overview of
Configuring Siebel Applications > About Scripting and Object
Interfaces > Generating Browser Scripts

• SupportWeb:
• Alert 365: Browser Script Generation in Siebel 7.x and 8.x
• Alert 466: Genbscript must be run after Distribution of SRF
Upgrade kit to Mobile Web Client for Version 7.0.3 and
higher.

49
<Insert Picture Here>

Flow of Execution

50
Scripting flow Control

• For any given process, scripted events on both the


browser and server sides will be invoked.

• Important to understand:
• The way in which events are called.
• What is possible in different environments (HI vs SI)
• How to communicate between application layers

51
Scripting Flow Diagram

52
Enabling a Custom Button on an Applet

• Two possible approaches:


• Code in the ‘WebApplet_PreCanInvokeMethod’ server event:

function WebApplet_PreCanInvokeMethod (MethodName, &CanInvoke)


{
if(MethodName == “TEST")
{
CanInvoke = "True";
return(CancelOperation);
}
return (ContinueOperation);
}

Where ‘TEST’ is the method defined against the button’s ‘Method


Invoked’ property.

53
Enabling a Custom Button on an Applet (cont’d)

WebApplet_PreCanInvokeMethod

54
Enabling a Custom Button on an Applet (cont’d)

• ‘Named Method’ Applet User Property:


Name: Named Method: TEST Value: 'INVOKE',
‘TEST’

55
Enabling a Custom Button on an Applet (cont’d)

• ‘Named Method’ BC User Property:


Name: Named Method: TEST Value: 'INVOKE',
‘TEST’

56
Enabling a Custom Button on an Applet (cont’d)
Button Press

“ContinueOperation”
Applet_PreInvokeMethod WebApplet_PreInvokeMethod

CancelOperation
ContinueOperation

ContinueOperation
BusComp_PreInvokeMethod

“CancelOperation” Default BC CancelOperation


Processing

No Server Side
WebApplet_InvokeMethod
processing if
handled on
browser side Applet_InvokeMethod
Server
Browser DONE

57
Scripting flow Control

Demo to show examples of flow of


execution and use of ‘ContinueOperation’
and ‘CancelOperation’

58
<Insert Picture Here>

Business Services

59
What are Business Services?
• Reusable, independent objects that encapsulate and simplify the
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
Types of Business Services

• Prebuilt: Specialised functionality pertaining to specific


application object(s):
• Functionality documented in Bookshelf - invocation supported.
e.g. ‘Workflow Process Manager’ BS used to invoke a Workflow Process.
• Functionality not documented in Bookshelf - invocation NOT supported

• Custom: Customer defined business processing defined in:


• Siebel Tools
• Web Client Business Service Administration

61
Types of Business Services - Custom
• 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.

• In Siebel Client (Run-Time BS):


• Created at run time in Siebel Client ‘Business Service
Administration’ screens.
• Can be tested in the ‘Business Service Simulator’ view,
without requirement to recompile SRF.
• Stored in the Siebel Database and have to be manually
moved over after an upgrade process.

62
Invoking a BS from Browser Script
Invoke Method

“ContinueOperation”
Service_PreInvokeMethod Service_PreInvokeMethod

Continue Operation

CancelOperation
Default Service
Processing
“CancelOperation”

Service_InvokeMethod
No Server Side
processing if
Server handled on
Service_InvokeMethod
Browser browser side

DONE

63
Invoking a Custom BS from Browser Script

• Declare in [SWE] section of CFG file:


• ClientBusinessService1 = xxx
• Alert 613: “Registering Business Services Called from Browser Script in Siebel
Applications”

• Return ‘CancelOperation’ in ‘Service_PreInvokeMethod’ event to stop


“Method xxx is not supported….” error occurring.

64
Invoking a Custom BS from Server Script

• Only server side events are invoked.

• No need to declare custom BS in [SWE] section of


CFG.

• Return ‘CancelOperation’ in ‘Service_PreInvokeMethod’ event to


stop “Method xxx is not supported….” error occurring.

65
Syntax for invoking BS

• Browser
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
<Insert Picture Here>

Implementation
Considerations and Best
Practices

67
Best Practices - General
• Siebel Scripting provides a powerful and flexible way to
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
Best Practices - General
• 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
Best Practices – Exception Handling
• 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
<Insert Picture Here>

Testing & Debugging

71
Debugging Options - Server

• Tools Debugger - use of Breakpoints, and debug toolbar to step through code.

• Tracing (‘TraceOn’, ‘TraceOff’)


Technical Note 485: “Using TraceOn, Trace, and TraceOff methods in Siebel Script”

• Log file
• Web Client - Set tracing on Object Manager
• Dedicated Web Client - Set ‘SIEBEL_LOG_EVENTS’ System Environment Variable to 4 or 5

• Custom logging to text file (‘Clib’ object)

eScript: Siebel VB:


var fp=Clib.fopen(“C:\\debug.txt”,”at”); Open “D:\debug.txt” For Append As 1
Clib.fputs(“ \n”,fp); write #1, “query expression = “ & x
Clib.fclose(fp); Close #1

72
Debugging Options – Browser

• theApplication().SWEAlert();
• FileSystemObject
var fso = new ActiveXObject(“Scripting.FileSystemObject”);
var a = fso.CreateTextFile(“c:\\debug.txt”, true);
// var a = fso.OpenTextFile(“c:\\debug.txt”, 8, false);
a.WriteLine(“Output to debug file…...”);
a.Close();

73
v8 Enhancements - Debugging with
ST Scripting Engine

74
v8 Enhancements – ‘Fix And Go’
• Allows changing a script in a local Tools Debugging session and directly
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
<Insert Picture Here>

APPENDIX A
Server Side Scriptable Object Events
(See also Bookshelf > Siebel Object Interfaces Reference Guide)

76
Application Object

77
Server Scripting – Application object
Application_Start event

• 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
Server Scripting – Application object
Application_Close event

• 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
Server Scripting – Application object
Application_PreInvokeMethod event

• 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
Server Scripting – Application object
Application_InvokeMethod event

• 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
Server Scripting – Application object
Application_PreNavigate

• 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
Server Scripting – Application object

Application_Navigate

• 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
Business Component
Object

84
Server Scripting – Buscomp object
Buscomp_PreNewRecord

• 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
Server Scripting – Buscomp object
Buscomp_NewRecord

• 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
Server Scripting – Buscomp object
Buscomp_PreCopyRecord

• 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
Server Scripting – Buscomp object
Buscomp_CopyRecord

• 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
Server Scripting – Buscomp object
Buscomp_PreDeleteRecord

• 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
Server Scripting – Buscomp object
Buscomp_DeleteRecord

• 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
Server Scripting – Buscomp object
Buscomp_PreWriteRecord

• 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
Server Scripting – Buscomp object
Buscomp_PreWriteRecord

Notes:

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.

When associating a multi-value group record (based on an M:M relationship)


with the business component that invokes the association, the PreWriteRecord
and WriteRecord events execute. These events execute even if no fields on
the base or invoking business component are updated by the association. The
PreWriteRecord and WriteRecord events are executed to acknowledge the
update to the intersection table.

92
Server Scripting – Buscomp object
Buscomp_WriteRecord

• 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
Server Scripting – Buscomp object
Buscomp_PreSetFieldValue

• 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 field’s 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
field’s property ImmediatePostChanges = “True” else the event will be
triggered for all fields when the record is written.

94
Server Scripting – Buscomp object
Buscomp_SetFieldValue

• 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
field’s 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
Server Scripting – Buscomp object
Buscomp_PreGetFieldValue

• 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
Server Scripting – Buscomp object
Buscomp_PreQuery

• 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
Server Scripting – Buscomp object

Buscomp_Query

• 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
Server Scripting – Buscomp object
Buscomp_PreInvokeMethod

• 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
Server Scripting – Buscomp object

Buscomp_ChangeRecord

• 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
Server Scripting – Buscomp object

Buscomp_PreAssociate

• 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
Server Scripting – Buscomp object
Buscomp_Associate

• 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
Server Scripting – Applet object
WebApplet_PreInvokeMethod

• 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
Server Scripting – Applet object

WebApplet_InvokeMethod

• 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
Server Scripting – Applet object
WebApplet_PreCanInvokeMethod

• 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
Server Scripting – Applet object

WebApplet_PreCanInvokeMethod

• Example (eScript)

function WebApplet_PreCanInvokeMethod (MethodName, &CanInvoke)


{
if (MethodName == "CustomMethod")
{
CanInvoke = "TRUE";
return(CancelOperation);
}

return (ContinueOperation);
}

• Note the value “TRUE” returned is a string, and is not a boolean

107
Server Scripting – Applet object
WebApplet_Load

• 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
Server Scripting – Applet object
WebApplet_ShowControl

• 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
Server Scripting – Applet object
WebApplet_ShowControl

• 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
Server Scripting – Applet object
WebApplet_ShowControl

• 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
Server Scripting – Applet object
WebApplet_ShowListColumn

• 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
Server Scripting – Applet object
WebApplet_ShowControl

• 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
Server Scripting – Applet object
WebApplet_ShowListColumn

• 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

Вам также может понравиться