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? • Architecture • Server Script • Browser Script • Flow of Execution • Business Services • Implementation Considerations and Best Practices • Testing and Debugging • Appendix <Insert Picture Here> 4 .

<Insert Picture Here> Siebel Scripting Overview 5 .

• Siebel 7 supports: • The use of both Siebel VB and eScript for Object Manager (server) side scripting. 6 .What is Siebel Scripting? • A multilingual coding mechanism used to provide extended functionality to an otherwise declaratively configured Siebel application. • Javascript for client (browser) side scripting.

where use of available declarative alternatives is either not practical or possible to achieve a business requirement. based upon data internal or external to Siebel • Communication with external sources. • Common usage scenarios might include • Simple or complex customer specific data validation rules. via • Workflow processes • Business Services and Transport Adapters (EAI) • Virtual Business Components (VBCs) • Dynamic user interaction with the user 7 .Siebel Scripting Capabilities • Siebel Scripting provides a flexible mechanism for extending Siebel eBusiness Applications.

8 . and access to the DOM (Document Object Model) objects in Standard Interactivity (SI) mode • Browser scripts are downloaded to the client. 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. to execute within the framework of the browser.Siebel 7 Scripting • The distinction between server and browser side scripts • Server scripts are written in Siebel VB or eScript • Authored in Siebel Tools. 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.

<Insert Picture Here> Architecture 9 .

Architecture Client Side Web Client Desktop Apps Web Server SWE Siebel Server Server Side Object Manager 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 .

5+ Mozilla Firefox (for SI mode apps only) 12 .Architecture Supported Platforms for scripting languages Language Siebel Visual Basic (VB) eScript Javascript Platform Windows only Windows Unix MS Internet Explorer 5.

• For more information refer to the following bookshelf references: • Siebel eScript Language Reference Guide • Siebel VB Language Reference Guide 13 . • It is left to the engineer to perform self study to become familiar with the functionality and syntax of these programming languages.Architecture • eScript and Siebel Visual Basic • This training course is not intended to teach these programming languages.

clicking an applet button or the user navigating to a new view. • 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. • For example it is possible to programmatically search for records in the database. 14 .Architecture • Events • The Siebel Scripting model is event driven model. they also support a range of standard methods that can be programmatically invoked from custom script. • Methods • In addition to supporting the placement of custom scripts on objects. perform updates to the current record from a custom script or programmatically invoke a business service.

Architecture • The standard events and methods supported by Siebel scripting are documented in the Siebel Tools online help. 15 . • 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.

A customer may also want to access Siebel data from a external application.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. • 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 . • 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.

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

EXE process. 19 .Server Scripting • Server Scripts run in the Object Manager • Mobile Web Clients execute server scripts locally within the object manager of the Siebel. • With the Siebel Handheld applications no custom scripts are executed on the device. Special consideration might need to be taken for this when implementing custom scripts. Instead the server scripts are executed at device synchronization time in a Siebel handheld deployment.

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 .

21 . • Select Edit Server Scripts menu option.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.

cfg file not in the Siebel repository. This setting is stored in tools.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. 22 . This can also be set default language in Tools > View > Options > Scripting dialog.

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 .

0.eScript Engines 7.5.8.x : T Engine 7.8.2.3 7.x : T Engine 7.x : T Engine 7.Server Scripting .7.x : T Engine 7.0 ST Engine ST Engine 27 .7.2.

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. 28 . Using strongly typed objects results in more functional scripts and faster performance. • Improved scalability: Lower footprint per user for CPU and memory use • New functionality: Added support for ECMAScript Edition 4 compliant strong typing. This will result in improved performance and lower garbage collection cost on heavily scripted events.

Enabling ST Script Engine in > 7.cfg files.7.2.srf = Siebel Tools = Siebel Tools = Tools = = Siebel Tools Client = Local = TRUE 29 . the ‘EnableCLIScripting’ parameter must be added to the [Siebel] section. as follows: [Siebel] RepositoryFile ApplicationName ApplicationTitle ApplicationSplashText Vertical ComponentName DataSource EnableCLIScripting … = siebel.3 • In the Siebel Tools and ALL client .

8.Enabling ST Script Engine in > 7.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 is capable of deducing the types of local variables by inspecting the assignments made to them. This allows the compiler to treat many of your typeless scripts as typed and you can enjoy the performance benefits and compilation warnings. and incorrect conversions. 33 . such as incorrect method names. • Deduce Types is a compiler option for deducing the types of local variables. variables that are be used before being assigned. whenever such a deduction can be made. The compiler can generate warnings for many problems that can otherwise cause runtime exceptions.

7.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.3 34 .2.

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 .

‘onblur’. for example.What is Browser Script? • JavaScript written to support: • Siebel object events and the DOM for. ‘onfocus’. generally. ‘onmouseout’ 38 .’onmouseover’. employee facing applications (HI) • DOM events only for customer facing applications (SI).’onclick’.

dependent on security settings on the client machine. That is.The Document Object Model (DOM) • Browser scripts can access the browser’s Document Object Model (DOM). 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 .

However you cannot call routines written in the General section from the DOM events. in a supported manner. in a supported manner.Supported DOM Events for HI Mode (cont’d) • NOTE: Siebel objects (business components. 43 . and so on.) cannot be accessed from DOM events. • To associate a script with the ‘control_OnClick’ event you need to use the ‘Applet_PreInvokeMethod’ event associated with the applet. applets. • Usually in scripting you can call routines in the General section from anywhere in the object.

Supported DOM Events for SI Mode 44 .

8 > Siebel Object Interfaces Reference > Browser Scripting > Supported DOM Events for Standard Interactivity Mode > Table 68 45 .Supported DOM Events for SI Mode (cont’d) Bookshelf 7.

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

• Located in <…\client\BIN> or <…\SIEBSRVR\BIN> directories • Run via command prompt • Syntax: genbscript <config file> <destination directory> [language] 47 .exe’ utility should be used when wishing to generate all browser scripts for a given SRF.Generating Browser Scripts (cont’d) • ‘genbscript.

cfg C:\ses75\SIEBSRVR\WEBMASTER 48 .exe C:\ses78\SIEBSRVR\BIN\ENU\uagent.exe C:\ses78\client\BIN\ENU\uagent.Generating Browser Scripts (cont’d) • Dedicated Web Client: C:\ses78\client\BIN\genbscript.cfg C:\ses78\client\PUBLIC\enu • Web Clients: C:\ses78\SIEBSRVR\BIN\genbscript.

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. 49 .0.x • Alert 466: Genbscript must be run after Distribution of SRF Upgrade kit to Mobile Web Client for Version 7.3 and higher.Generating Browser Scripts (cont’d) • Bookshelf (7.

<Insert Picture Here> Flow of Execution 50 .

• What is possible in different environments (HI vs SI) • How to communicate between application layers 51 .Scripting flow Control • For any given process. • Important to understand: • The way in which events are called. scripted events on both the browser and server sides will be invoked.

Scripting Flow Diagram 52 .

53 .Enabling a Custom Button on an Applet • Two possible approaches: • Code in the ‘WebApplet_PreCanInvokeMethod’ server event: function WebApplet_PreCanInvokeMethod (MethodName. return(CancelOperation). } return (ContinueOperation). } Where ‘TEST’ is the method defined against the button’s ‘Method Invoked’ property. &CanInvoke) { if(MethodName == “TEST") { CanInvoke = "True".

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

55 .Enabling a Custom Button on an Applet (cont’d) • ‘Named Method’ Applet User Property: Name: Named Method: TEST ‘TEST’ Value: 'INVOKE'.

56 .Enabling a Custom Button on an Applet (cont’d) • ‘Named Method’ BC User Property: Name: Named Method: TEST ‘TEST’ Value: 'INVOKE'.

Enabling a Custom Button on an Applet (cont’d) Button Press Applet_PreInvokeMethod “ContinueOperation” WebApplet_PreInvokeMethod CancelOperation ContinueOperation ContinueOperation “CancelOperation” Default BC Processing BusComp_PreInvokeMethod CancelOperation WebApplet_InvokeMethod Applet_InvokeMethod Server Browser No Server Side processing if handled on browser side 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. other objects to achieve a particular goal. or act upon. although exceptions for specialised cases also exist. 60 . Are not specifically tied to data or tables within the Siebel data model. They can be assessed either directly by way of Workflows (Business Processes). Can simplify the task of moving data and converting data formats between the Siebel application and external applications. General business services are based on the class ‘CSSService’. Objects that operate. or by way of script written against object(s) within the Repository.

Types of Business Services • Prebuilt: Specialised functionality pertaining to specific application object(s): • Functionality documented in Bookshelf .invocation NOT supported • Custom: Customer defined business processing defined in: • Siebel Tools • Web Client Business Service Administration 61 . ‘Workflow Process Manager’ BS used to invoke a Workflow Process. • Functionality not documented in Bookshelf .invocation supported. e.g.

Custom • • • • In Siebel Tools: Created at design time in Siebel Tools using Siebel VB or Siebel eScript. Can be tested in the ‘Business Service Simulator’ view. 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. Have to be compiled into SRF before testing possible. 62 .Types of Business Services . Stored in the Siebel Database and have to be manually moved over after an upgrade process. without requirement to recompile SRF.

Invoking a BS from Browser Script Invoke Method Service_PreInvokeMethod “ContinueOperation” Service_PreInvokeMethod Continue Operation Default Service Processing CancelOperation “CancelOperation” No Server Side processing if handled on browser side Service_InvokeMethod Server Browser Service_InvokeMethod DONE 63 .

” error occurring. 64 .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….

• Return ‘CancelOperation’ in ‘Service_PreInvokeMethod’ event to stop “Method xxx is not supported…. • No need to declare custom BS in [SWE] section of CFG.” error occurring.Invoking a Custom BS from Server Script • Only server side events are invoked. 65 .

GetService(“xxx”).InvokeMethod(“xxx”.GetService(“xxx”). psInput). oService. psOutput). var oService = TheApplication(). psInput. var oService = theApplication().NewPropertySet().NewPropertySet().Syntax for invoking BS • Browser var psInput = theApplication(). 66 .NewPropertySet().InvokeMethod(“xxx”. var psOutput = oService. var psOutput = TheApplication(). • Server var psInput = TheApplication().

<Insert Picture Here> Implementation Considerations and Best Practices 67 .

Primary references: Technical Note 514: Siebel Scripting Best Practices Bookshelf: ‘Performance Tuning Guide > Tuning Customer Configurations for Performance > Best Practices for Siebel Scripting’ 68 . • Poorly designed and implemented eScript or Siebel VB can directly and negatively impact the performance.Best Practices .General • Siebel Scripting provides a powerful and flexible way to customize your Siebel applications. adding scripting to Siebel applications increases the overall complexity of application maintenance and upgrades. thereby increasing the total cost of ownership. scalability. However. and system stability of your Siebel application implementation.

This is because a scripting solution may not be most effective or give best performance. Technical) 69 .General • Before resorting to using scripting you should always consider if there is a configuration based method of achieving the requirement.Best Practices . 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.

See future Brownbag session on Exception Handling • 70 .RaiseErrorText(e. } 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.Best Practices – Exception Handling • Implement exception handling code to handle unexpected errors in a controlled way and also perform “clean up” actions.toString()). 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().

<Insert Picture Here> Testing & Debugging 71 .

txt” For Append As 1 write #1.”at”). Clib. Clib. ‘TraceOff’) Technical Note 485: “Using TraceOn.txt”.Set ‘SIEBEL_LOG_EVENTS’ System Environment Variable to 4 or 5 • Custom logging to text file (‘Clib’ object) eScript: var fp=Clib. “query expression = “ & x Close #1 72 .Server • Tools Debugger .fputs(“ \n”. and debug toolbar to step through code.Debugging Options .fopen(“C:\\debug. and TraceOff methods in Siebel Script” • Log file • Web Client . Siebel VB: Open “D:\debug. Trace. • Tracing (‘TraceOn’.fp).use of Breakpoints.Set tracing on Object Manager • Dedicated Web Client .fclose(fp).

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

v8 Enhancements .Debugging with ST Scripting Engine 74 .

Save and compile final version of script before exiting Tools. Open client through Tools debugger environment and test script 3. Test altered code on client 6. Compile script once 2. Modify script 4.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. in order for changes to persist in non-debug client. • Repeat steps 3-5 as required before final recompile of SRF 75 . Save changes in Tools script editor 5.

<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

• 81 . The argument methodName is passed to the event. It will contains the name of the method that has just been successfully invoked.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.

else return ContinueOperation for the navigation to be allowed.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. This identifies the name of the view to which the user is navigating and the business object of the destination view. The arguments DestViewName and DestBusObjName are passed to the event. Return CancelOperation if the navigation should not proceed. • • 82 . This event can be used for validation and determining if the user should be allowed to navigate to the view.

• • 83 . You could place code on this event for example to initialize data when a user navigates to a specific view. Any code on this event will be executed if the PreNavigate event returned the value ContinueOperation.Server Scripting – Application object Application_Navigate • The Navigate event is called after the client has navigated to a view.

Business Component Object 84 .

Return CancelOperation if you do not want a new record to be created. This event may be used to perform validation to determine if user is permitted to create a new record.Server Scripting – Buscomp object Buscomp_PreNewRecord • The PreNewRecord event is called before a new row is created in the business component. • • 85 . It can also be triggered as result of custom code creating a new record in the buscomp. The event will be triggered by the user performing action in the user interface to create a new record in an applet. otherwise returning ContinueOperation will allow a new record to be created (standard behavior).

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. The Buscomp_Copy event will be triggered instead. 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. • • 86 . initialized due to configurations and made active.Server Scripting – Buscomp object Buscomp_NewRecord • The NewRecord event is called after a new row has been created in the business component.

• 87 . The event may be used to perform pre-copy validation. Return CancelOperation to prevent the new record being created.Server Scripting – Buscomp object Buscomp_PreCopyRecord • The PreCopyRecord event is called before a new row is copied in the business component. or ContinueOperation to allow the record to be created and initialized.

NewRecord(NewAfterCopy or NewBeforeCopy) through any UI copy record mechanism (Edit > Copy Record.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. CTRL+B) • 88 .

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. TheApplication.GetFieldValue(fieldname) To prevent the record from being deleted return CancelOperation. In this event you can evaluate the current value of fields within the record to be deleted using this. This event may be used to perform validation checking to evaluate if the deletion should proceed.Server Scripting – Buscomp object Buscomp_PreDeleteRecord • The PreDeleteRecord event is called before a row is deleted in the business component. otherwise return ContinueOperation to allow the record to be deleted. • • • • 89 .

Server Scripting – Buscomp object Buscomp_DeleteRecord • • The DeleteRecord event is called after a row is deleted. • 90 . When a user reads and deletes an existing record or creates and then undoes the new record. The current context is a different row (the Fields of the just-deleted row are no longer available). this invokes the DeleteRecord method and will results in the execution of any scripts on the PreDeleteRecord and DeleteRecord events.

Return CancelOperation if you do not want the record to be written to the database. PreWriteRecord is called to delete the implied join records to the initial record. In this event you perform any final validation necessary before the actual save occurs. 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. • • 91 .Server Scripting – Buscomp object Buscomp_PreWriteRecord • The PreWriteRecord event is called before a new or updated row is written to the database.

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. or when a record is deleted. the PreWriteRecord and WriteRecord events execute.Server Scripting – Buscomp object Buscomp_PreWriteRecord Notes: The PreWriteRecord event triggers only if a field value was modified or inserted. These events execute even if no fields on the base or invoking business component are updated by the association. 92 . The PreWriteRecord and WriteRecord events are executed to acknowledge the update to the intersection table. When a record is deleted.

put it a PreWriteRecord event. If you need to use SetFieldValue. Do not use SetFieldValue in a WriteRecord event. The WriteRecord event triggers after the record has been committed to the database.Server Scripting – Buscomp object Buscomp_WriteRecord • The WriteRecord event is called after a row is written out to the database. • • 93 .

It is possible to implement code on this event to perform validation and or maybe perform a calculation based on the new field value. The argument FieldName is a string containing the name of the changed field.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 FieldValue is a string containing the changed 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 . Return CancelOperation if you want to reject the new value and force the user to re-enter a new value.

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. The argument FieldName is a string containing the name of the changed field. It will be triggered if any corresponding code on the PreSetFieldValue event returns the value ContinueOperation. This event is not triggered for any predefaulted or calculated fields in Siebel Tools. • • 95 .

Populate the argument FieldValue using your custom code with the desired value and return CancelOperation from the event. This occurs when and applet needs to display data to the user or when custom code utilizes the GetFieldValue method. 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 . You can use this event to implement fields that are based on a complex calculation that needs to be implemented in code.Server Scripting – Buscomp object Buscomp_PreGetFieldValue • The PreGetFieldValue event is called when the value of a business component field is accessed. The argument FieldName is a string containing the name of the field being accessed .

Return CancelOperation if your want to prevent the query from being executed against the database. • • • • 97 .GetSearchSpec() or this.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. Use this. This event may be used to perform validation and also modify the search criteria or to restrict the execution of certain queries. Use SetSearchSpec() or SetSearchExpr() buscomp methods to modify the search spec.GetSearchExpr() buscomp methods to get current search specification that will be used for the query.

For example to display a popup message to the user if the query returned any data with a certain status. • 98 . You could place code on this event to perform check on the data retrieved by the query. but before the data is actually displayed in the UI.Server Scripting – Buscomp object Buscomp_Query • The Query event is called just after the query is complete and the data haw been retrieved.

Returning ContinueOperation allows a standard specialized class method to be executed. 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.Server Scripting – Buscomp object Buscomp_PreInvokeMethod • The PreInvokeMethod event is called before any specialized or custom methods are invoked on the business component. Custom methods at buscomp level usual refer to field values within the current records context: for example this. There is no input property set. • • • • • 99 .GetFieldValue(“fieldname”) Return CancelOperation at the end of a custom method.

Avoid lengthy operations in this event handler to enable smooth scrolling in list applets.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. • • 100 .

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

You can implement code on this event to perform validation check to see if the association should proceed. This event is applicable to buscomps in a many to many relationship.Server Scripting – Buscomp object Buscomp_Associate • The PreAssociate event is called before a record is added to a business component to create an association. Return CancelOperation to prevent the association or RaiseErrorText(). The semantics are the same as for BusComp_PreNewRecord. • • • 102 .

Applet Object 103 .

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.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. Place code in this event to override or supplement standard functionality of an applet. • • • • 104 . 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.

Argument methodName is a string variable containing the name of the method that was invoked. • • 105 . You could implement custom code here if you wanted implement additional application behaviour to occur after a standard or specialized method has completed execution.Server Scripting – Applet object WebApplet_InvokeMethod • The PreInvokeMethod event is called after a method has been sucessfully invoked against the applet.

Valid values are TRUE or FALSE. • • • 106 . Return CancelOperation at the end of your custom code. This event determines if a button that invokes the method will be enabled in the user interface. 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.Server Scripting – Applet object WebApplet_PreCanInvokeMethod • The PreCanInvokeMethod event is called before the PreInvokeMethod and also when an applet is loaded. Argument &CanInvoke is a string representing whether or not the Applet method can be invoked. Custom code in this event should populate the CanInvoke variable with the value “TRUE” in order for the button to be enabled.

Server Scripting – Applet object WebApplet_PreCanInvokeMethod • Example (eScript) function WebApplet_PreCanInvokeMethod (MethodName. } return (ContinueOperation). and is not a boolean 107 . return(CancelOperation). } • Note the value “TRUE” returned is a string. &CanInvoke) { if (MethodName == "CustomMethod") { CanInvoke = "TRUE".

You can implement code on this event to perform initialization code. • • 108 . for example to programmatically set the search specification for a pick applet.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.

Argument property is a string indicating the value of the property attribute of the swe:control or swe:this tag that triggers this event. Sort Argument &HTML is a string containing the HTML generated by the Siebel Web Engine for the control. Argument controlName is a string indicating the name of the control to be rendered. New. it can also be an empty string if this attribute is not specified for the tag. possible modes are: Base. Argument mode is a string indicating the mode of the applet that is currenlty being shown. • • • • 109 .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. Query. Edit.

See future Brownbag session covering ShowControl event for more detail regarding usage.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. • • • 110 .

Server Scripting – Applet object WebApplet_ShowControl • Example This Siebel eScript script displays negative amounts in red in a read-only form. Property. function WebApplet_ShowControl (ControlName. &HTML) { if( ControlName == "Amount" && Mode == "Base" && Property == "FormattedHTML") { var bc = this. if (amount < 0) HTML = "<FONT Color=Red> " + HTML + " </FONT>".GetFieldValue("Transaction Amount")). } } 111 . Mode.BusComp(). var amount = ToNumber(bc.

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. Edit. Argument property is a string indicating the value of the property attribute of the swe:control or swe:this tag that triggers this event. New. • • • • 112 . Argument controlName is a string indicating the name of the list column to be rendered. Argument mode is a string indicating the mode of the applet that is currenlty being shown. possible modes are: Base. it can also be an empty string if this attribute is not specified for the tag. Query. Sort Argument &HTML is a string containing the HTML generated by the Siebel Web Engine for the list column.

See Brown bag session covering ShowListColumn event for more detail regarding usage. • • • 113 .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.

&HTML) { if ((ColumnName == 'Amount') && (Mode == "Base") && (Property == "FormattedHTML")) { HTML = "<FONT Color=Red> " + HTML + " </FONT>". Property. } } 114 . Mode. function WebApplet_ShowListColumn (ColumnName.Server Scripting – Applet object WebApplet_ShowListColumn • Example This Siebel eScript script displays the amounts in a list column in red.