Siebel 8.1.x Scripting
-
Upload
khangminh22 -
Category
Documents
-
view
3 -
download
0
Transcript of Siebel 8.1.x Scripting
Siebel 8.1.x Scripting
Student Guide
D61663GC10
Edition 1.0
October 2009
D63187
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Copyright © 2009, Oracle. All rights reserved.
Disclaimer
This document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way. Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display, perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization of Oracle.
The information contained in this document is subject to change without notice. If you find any problems in the document, please report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not warranted to be error-free.
Restricted Rights Notice
If this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United States Government, the following notice is applicable:
U.S. GOVERNMENT RIGHTSThe U.S. Government’s rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted by the terms of the applicable Oracle license agreement and/or the applicable U.S. Government contract.
Trademark Notice
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
iii
Table of Contents
Lesson i Course Introduction
Lesson 1 Introducing Siebel Scripting
Lesson 2 Exploring Alternatives to Scripting
Lesson 3 Siebel Event Handling
Lesson 4 Coding and Debugging in the Siebel Tools Script Editor
Lesson 5 Scripting Using the Siebel Object Interfaces
Lesson 6 Accessing Object Instances in Siebel Scripts
Lesson 7 Writing Good Scripts
Lesson 8 Scripting Custom Business Services
Lesson 9 Invoking Business Services
Lesson 9a Scripting Project
Lesson 10 Browser Script Techniques
Lesson 11 Measuring and Improving Script Performance
Appendix A Siebel eScript Programming
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Copyright © 2009, Oracle. All rights reserved.
Siebel 8.1.x Scripting:Course Introduction
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting I - 2
Copyright © 2009, Oracle. All rights reserved.
Lesson Agenda
• This Lesson provides an introduction to the:– Instructor and class participants
– Training site information
– Course:— Audience
— Prerequisites
— Goal
— Objectives
— Methodology
— Materials
— Agenda
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting I - 3
Copyright © 2009, Oracle. All rights reserved.
Instructor and Class Participants
• Who are you?– Name
– Company
– Role
• What is your prior experience?– Siebel applications
– Siebel Tools and configuration
– Programming and Web development
• How do you expect to benefit from this course?
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting I - 4
Copyright © 2009, Oracle. All rights reserved.
Training Site Information
Rest rooms
Telephones
Fire Exits
Class duration and breaks
Meals and refreshments
Questions?
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting I - 5
Copyright © 2009, Oracle. All rights reserved.
Course Audience
• This course is designed for implementation team members who will script custom functionality in a Siebel application– Developers
– Configurators
– Other implementation team personnel
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting I - 6
Copyright © 2009, Oracle. All rights reserved.
Course Prerequisites
• Required:– Siebel 8.0 Technical Foundations
• Recommended:– Siebel 8.0 Fundamentals
– Siebel 8.1.x Tools
– Siebel 8.1.x Business Automation
– Prior programming experience
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting I - 7
Copyright © 2009, Oracle. All rights reserved.
Course Goal
• To enable participants to write correct scripts when scripting is necessary
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting I - 8
Copyright © 2009, Oracle. All rights reserved.
Course Objectives
• Describe when to use scripting in a Siebel application implementation
• Describe Siebel event handling
• Create and execute server and browser scripts
• Use the Siebel Tools Script Editor to author and debug scripts
• Script using the Siebel Object Interfaces
• Script a custom business service
• Invoke scripts from the Siebel user interface
• Tune scripts using the Siebel Script Performance Profiler and Siebel Application Response Measurement (SARM)
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting I - 9
Copyright © 2009, Oracle. All rights reserved.
Course Methodology
• Subject matter is delivered through: – Web-delivered presentations
– Software demonstrations
– Class discussions
– Hands-on practices
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting I - 10
Copyright © 2009, Oracle. All rights reserved.
Course Materials
• Course content is delivered over three days
• Student Guide– All slides presented during lecture
– Student notes with references to the Siebel Bookshelf documentation library
• Activity Guide– Hands-on exercises and solutions
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting I - 11
Copyright © 2009, Oracle. All rights reserved.
Siebel Documentation
• Siebel applications are documented in Siebel Bookshelf, a searchable collection of guidebooks– Bookshelf is also called Siebel Business Applications
Documentation Library
– Updated regularly
• In the classroom, Siebel Bookshelf is available on Oracle Technology Network – www.oracle.com/technology/documention/siebel.html
– Make sure you are using the appropriate version of Bookshelf
— Example: Siebel 8.1
Siebel Documentation
References in the lessons to Siebel Bookshelf use the convention Bookshelf Title, “Chapter Name”.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting I - 12
Copyright © 2009, Oracle. All rights reserved.
Feedback
• If you have feedback on this or other Siebel courseware, please email [email protected]
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting I - 13
Copyright © 2009, Oracle. All rights reserved.
Introduction to Scripting
• Lesson 1: Introducing Siebel Scripting
• Lesson 2: Exploring Alternatives to Scripting
Scripting Fundamentals
• Lesson 3: Siebel Event Handling
• Lesson 4: Coding and Debugging in Siebel Tools’ Script Editor
• Lesson 5: Scripting Using the Siebel Object Interfaces
• Lesson 6: Accessing Object Instances in Server ScriptsLesson 7: Writing Good Scripts
Course Agenda
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting I - 14
Copyright © 2009, Oracle. All rights reserved.
Creating and Invoking Custom Business Services
• Lesson 8: Creating Custom Business Services
• Lesson 9: Invoking Business Service Methods
• Practice 9a: Scripting Project
Other Topics
• Lesson 10: Browser Script Techniques
• Lesson 11: Measuring and Improving Script Performance
Appendix
• Appendix A: Siebel eScript Programming
Course Agenda
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting I - 15
Copyright © 2009, Oracle. All rights reserved.
Summary
• This lesson provided an introduction to the:– Instructor and class participants
– Training site information
– Course:— Audience
— Prerequisites
— Goal
— Objectives
— Methodology
— Materials
— Agenda
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting I - 16
Copyright © 2009, Oracle. All rights reserved.
Practice 0 Overview: Preparing the Classroom Environment
This practice covers the following topics:
• Exiting any existing Siebel applications
• Running the classroom refresh utility to prepare the classroom for this course
Note: Successfully completing this practice is critical to ensure subsequent practices behave as expected.
Preparing the Classroom Environment
Practices for this and all other lessons are found in the course’s Activity Guide.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Copyright © 2009, Oracle. All rights reserved.
Introducing Siebel Scripting
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 2
Copyright © 2009, Oracle. All rights reserved.
Objectives
After completing this lesson, you should be able to:
• Describe the Siebel 8 scripting environment
• Define browser and server scripts
• List appropriate uses of scripting
• List reasons to avoid scripting
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 3
Copyright © 2009, Oracle. All rights reserved.
Siebel Scripting
• Allows the use of scripting languages to enhance and extend the functionality of Siebel applications
• Is typically performed by developers using Siebel Tools:– Developing scripts is not an administrative role
• Requires strong technical knowledge of:– Programming and software testing
– Familiarity with software development methodology and best practices
– The Siebel Object Model and Siebel capabilities
Siebel Scripting
Scripting is covered in several references in Siebel Bookshelf:• Using Siebel Tools• Siebel Object Interfaces Reference• Siebel eScript Language Reference• Siebel VB Language Reference O
racl
e U
nive
rsity
and
(Ora
cle
Cor
pora
tion)
use
onl
y.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 4
Copyright © 2009, Oracle. All rights reserved.
Browser and Server Scripts
• There are two different script types:– Browser scripts
— Are interpreted and executed at run time by the Web browser
— Are executed by the browser for both Web and Mobile or Dedicated clients
– Server scripts— Are interpreted and executed at run time by the Application
Object Manager (AOM)— If using the Web client, the AOM runs on the Siebel Server
— If using Siebel Mobile Web Client or Siebel Developer Web Client, the AOM runs as part of the client executable (siebel.exe)
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 5
Copyright © 2009, Oracle. All rights reserved.
Script Languages
• Browser Scripts are written in JavaScript
• Server Scripts can be written in either:– Siebel Visual Basic (Siebel VB)
— Syntax similar to Microsoft Visual Basic for Applications
— Supported on Windows platform only
– Siebel eScript— Based on ECMAScript, the industry-standard JavaScript
— Supported in both UNIX and Windows environments
Browser Scripts Server Scripts
JavaScript Siebel VBeScript
Script Languages
JavaScript
JavaScript is a Web development language that is syntactically similar to Java or C. Despite its name, JavaScript is not related to or derived from the Java programming language.
Server Script Languages
A server script is added to an object definition, such as a Business Service object definition. A Siebel application can support scripts in both Siebel VB and eScript. All server script attached to a specific object must be written in the same language.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 6
Copyright © 2009, Oracle. All rights reserved.
Browser Scripts
• Are added to available object definitions using Siebel Tools
• Are compiled into .js (JavaScript) files and uploaded to the Web server
• Are downloaded to a user’s browser during a user session
• Are invoked by user activity in the browser
• Are executed by the JavaScript interpreter within the browser
.jsTools
Compile
Invoke
Execute
Add
Download
Web Server Browser.js
Upload
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 7
Copyright © 2009, Oracle. All rights reserved.
Browser Script Considerations and Usage
• Web development skills are useful– Browser scripting uses Web standards, such as JavaScript,
ActiveX, and Document Object Model (DOM)
• Need an external debugger – For example: Microsoft Script Editor
• Must deploy .js files to the Siebel Web server and remote clients
• Browser script examples:– User interaction
– User interface (UI) manipulation, such as changing text color
– Server script needs data that is only available in browser script
— Example: Pass the active business component in a user session to a server script
Browser Script Considerations and Usage
Browser Scripts
Browser scripts are covered in detail in a later lesson.
Active Business Component
A server script has access to the current business object, which is associated with the currently displayed view in the user’s session. However, a server script does not have access to the applet in focus in the current view, and thus does not know the current, active business component.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 8
Copyright © 2009, Oracle. All rights reserved.
Server Scripts
• Are added in Siebel Tools or the Siebel client to object definitions:– Applet, Application, Business Component, or Business
Service
• Are invoked when an event occurs, such as user activity in the browser or execution a workflow process
• Are executed by the interpreter .dll
.srfTools DLL
2. Compile
3. Invoke4. Execute1. Add
5. Result
Object Manager
UI Activity or Workflow
Server Scripts
Repository-Based and Client-Entered Server Scripts
As will be covered in a later lesson, server scripts can be created in two different ways:• Repository-based server scripts are created in Siebel Tools, and are compiled into the Siebel
repository file (.srf). • Client-entered server scripts are created in the Siebel client.
Repository-based server scripts have far greater development and debugging support and will be the focus of this course. Client-entered server scripts are discussed briefly in a later lesson.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 9
Copyright © 2009, Oracle. All rights reserved.
Server Script Usage
• Functionality not related to the UI or a user session
• Data operations (Create, Read, Update, Delete) without user notification
• Collect data unavailable to browser scripts and pass data back to the calling browser script– Example: Use NextSelected() to parse all records in the
user’s selection
• Create a custom business service– Can be used in a Siebel workflow process
– Can be exposed as a Web service
• Siebel Workflow– Cannot call browser-based business services from workflow
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 10
Copyright © 2009, Oracle. All rights reserved.
Siebel T and ST eScript Engines
• Siebel applications support two different eScript scripting engines for server scripting:– eScript ST engine (default):
— Introduced in Siebel 7.8
— Offers enhanced features (discussed on following slides)
– eScript T engine: for compatibility with Siebel 7.7 and earlier
• Set a system preference to select which engine is used– Navigate to Administration - Application > System
Preferences
– Set Enable ST Engine to TRUE or FALSE
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 11
Copyright © 2009, Oracle. All rights reserved.
eScript ST Engine Features
• Offers support for:– Type and typeless variables
– Late and early binding class support
– Script Assist features in Siebel Tools
• Script Assist features are covered in a later lesson
More
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 12
Copyright © 2009, Oracle. All rights reserved.
• The ST scripting engine supports both typeless variables and typed variables
• Typed variables allow the compiler to detect type mismatches– Eliminates a common source of scripting errors
• Examples:
eScript ST Engine Features: Typed and Typeless Variable Support
var welcome = "hello";var now = new Date();
var welcome : chars = "hello";var now : Date = new Date();
Typeless variable declarations
Typed declarations for the same
variables
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 13
Copyright © 2009, Oracle. All rights reserved.
eScript ST Engine Features: Late and Early Binding Support
• Binding refers to the association of identifiers with run-time entities such as objects
• Late binding indicates that binding occurs at run time:
var str;var now = new Date();str = now.toString(); Binding of now to Date
object occurs at run time
Variable now has typeless declaration, so…
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 14
Copyright © 2009, Oracle. All rights reserved.
eScript ST Engine Features: Late and Early Binding Support
• Early binding indicates that binding occurs at compile time
• Early binding results in:– Better script performance because no binding occurs during
script execution
– Less memory use because no need for run-time structures to support late binding
var str : String;var now : Date = new Date();str = now.toString(); Binding of now to Date object
occurs at compile time
Variable now has typed declaration, so…
5
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 15
Copyright © 2009, Oracle. All rights reserved.
Integrated Script Development Environment
• Siebel Tools includes an integrated development environment (IDE) with a: – Script editor
— Full-functioned, "Siebel-aware" editor
— Server scripts are stored in the repository database: there are no separate development files to manage
– Compiler— Compiles server scripts into the .srf file
— Remember: script execution is interpreted
– Debugger for server scripts— Similar to other standard debugging tools
– Script Performance Profiler— Measures script execution
— Is used to optimize script performance
Integrated Script Development Environment
Siebel Tools Script Editor
Using the Siebel Tools Script Editor to write, test, and debug scripts is the topic of a later lesson.
Browser Script Files
Browser script files need to be deployed on the Siebel Web server. Browser scripts are the topic of a later lesson.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 16
Copyright © 2009, Oracle. All rights reserved.
Look for Alternatives to Scripting
• Most application requirements can be met without scripting
• Leverage standard application functionality– As-delivered functionality
– Administratively-configured functionality— Use the Siebel client to configure functionality
— Example: Siebel Audit Trail
– Declaratively-configured functionality — Modify object definitions using Siebel Tools
— Example: Configuring Business Component Field validation properties
• Alternatives to scripting are explored in the next lesson
Look for Alternatives to Scripting
The next lesson provides a methodology for exploring alternatives to scripting, and illustrates some commonly-used alternatives.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 17
Copyright © 2009, Oracle. All rights reserved.
Reasons to Avoid Siebel Scripting
Scripting
• Slows processing– Is interpreted at run time
• Introduces the potential for run-time errors
• Requires continued maintenance
• Introduces complexity
• Often reproduces functionality available through configuration
• Complicates the upgrade process
Reasons to Avoid Siebel Scripting
Scripting allows an implementation team to bypass or reproduce as-delivered Siebel application functionality. A team composed of experienced developers with little Siebel experience will typically script too much, and this can endanger project success. The next lesson presents a framework for exploring Siebel functionality as a way of avoiding scripting.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 18
Copyright © 2009, Oracle. All rights reserved.
Scripting Performance
• Excessive scripting can lead to significant performance impact:– Increased CPU utilization
– Larger RAM footprint
– Slower application response times
• This performance impact can be severe!
• Excessive scripting is also correlated with implementation project issues:– Oracle has found a historic correlation between "Red"
customer accounts and the amount of script used in the customer’s implementation project
Scripting Performance
Properly written scripts can perform and scale well, but poorly implemented scripts will significantly reduce performance. Scripting performance measurement and optimization is the topic of an upcoming lesson.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 19
Copyright © 2009, Oracle. All rights reserved.
User options (file export, tab order)
Built-in assistants (Activity plans)
Built-in functionality (Order, eSales)
State Model
Audit Trail
......
Validation Manager
Runtime Events
Personalization
.....
Siebel Workflow
Declarative configuration
Scripting – BC, Application Level
Scripting – Business Services
Scripting – Server Script
Scripting – Browser Script
LOE = Low•Standard functionality•Requires no or little administration•No configuration needed
LOE = Medium•Mostly standard functionality•Requires administration•Some configuration needed
LOE = High•Not standard functionality•Requires repository changes•Significant configuration needed
• Scripting requires very high LOE and costs
• Consider "cheaper" options first
Customization: Level of Effort (LOE)
Customization: Level of Effort (LOE)
The graphic shows a listing of options on the left in ascending order of level of difficulty or development effort.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 20
Copyright © 2009, Oracle. All rights reserved.
If You Need to Script
• Limit the amount of code to increase the quality of the code that you really need to have
• Apply software-industry standards for programming to your scripts– Exception handling
– Tracing
– Encapsulation
– Headers, comments
– Library of (translatable) error messages
– Quality assurance (QA)
– Testing methodology (unit testing, integration testing, performance analysis, and so on)
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 21
Copyright © 2009, Oracle. All rights reserved.
Lesson Highlights
• Scripting allows you to extend the functionality of Siebel applications
• Server scripts:– Are stored in the repository and compiled into the .srf file
– Are invoked when the object is changed, such as by user activity in the browser or by a workflow process
– Are written in eScript or Siebel VB
• Browser scripts:– Are invoked by user activity in the browser
– Are executed by the JavaScript interpreter within the browser
• Always look for Siebel-provided alternatives to scripting– Scripting may negatively impact performance
– Scripting may complicate upgrades
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 1 - 22
Copyright © 2009, Oracle. All rights reserved.
Practice 1 Overview: Exploring Scripts
This practice covers the following topics:
• Locate server and browser scripts in Siebel Tools
• Access scripting documentation in Siebel Tools
• Create and run a simple script
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Copyright © 2009, Oracle. All rights reserved.
Exploring Alternatives to Scripting
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 2
Copyright © 2009, Oracle. All rights reserved.
Objectives
After completing this lesson, you should be able to:
• Describe several administrative alternatives to scripting
• Describe several declarative alternatives to scripting
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 3
Copyright © 2009, Oracle. All rights reserved.
The Critical Scripting Question
• Is there a way to implement an application requirement without scripting?– Leverage standard functionality
— State Model, Activity Plans, Siebel Workflow, and so on
– Identify declarative alternatives— User properties, field properties, built-in business services, and
so on
• This question is important because:– Scripting is the most expensive and most error-prone
approach to implement requirements
– Upgrading to the next Siebel release will be more difficult if more script exists in the repository
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 4
Copyright © 2009, Oracle. All rights reserved.
Built-In and Configurable Functionality
• Alternatives to scripting can be categorized by level of effort required to meet application requirements, from least to most effort required:– As-delivered functionality
— Features that are built in to the as-delivered application
– Administrative-configured functionality— Features that can be configured primarily using the Siebel client
– Declaratively-configured functionality— Features that can be configured primarily using Siebel Tools
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 5
Copyright © 2009, Oracle. All rights reserved.
As-Delivered Alternatives to Scripting
• As-delivered Siebel applications have built-in functionality that is:– Determined by the user interface (UI) objects (screens,
views, and applet) and the navigation between them
– Entities in the Siebel Logical Model— Refers to business objects, business components, and the
relationships between different entities
– Pre-configured functions, usually executed by UI controls or menu items
— Examples:— Convert a Quote into an Order
— Calculate lowest Commit time for a Service Request based on one or more customer warranties or service level contracts
— Export Account Data to a comma-delimited file
As-Delivered Alternatives to Scripting
References
Bookshelf has a variety of application- and industry-specific manuals that can help you become acquainted with Siebel functionality. For example: the Siebel Order Management Guide covers details of handling quotes and orders, and the Siebel Life Sciences Guide documents the three industry applications Siebel Pharma, Siebel Medical, and Siebel Clinical. The Siebel Data Model Reference and the Siebel Data Model Reference for Industry Applications Reference describe the Siebel Logical Model through entity-relationship diagrams and documentation. These two references also discuss the Siebel data layer.
Pre-Configured Functions
Many as-delivered functions available in the Siebel UI require additional configuration through an administrative interface. For example, as-delivered applications support sales forecasting, but administrative data about sales periods and organizational structure has to be entered before producing meaningful forecasts.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 6
Copyright © 2009, Oracle. All rights reserved.
Administrative Alternatives to Scripting
• Administrative functions that do not typically require changes to the .srf file– Are configured in the Siebel client using Administration
screens
– Have been developed and performance-tested by Oracle
– Are well documented
Administrative Alternatives to Scripting
Reference
Many titles in Siebel Bookshelf cover administrative functionality. A good place to start for more information is the Siebel Applications Administration Guide.
Diagram
The picture shows some of the many Administration screens available through the Site Map. To access these screens, a user will need an administrative responsibility.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 7
Copyright © 2009, Oracle. All rights reserved.
Examples of Administrative Alternatives to Scripting
• Some important administrative alternatives to scripting are:– Personalization
– Runtime Events
– State Model
– Data Validation Manager
– Audit Trail
– Assignment Manager
Examples of Administrative Alternatives to Scripting
The list covered in the following slides presents some of the more important administrative alternatives to scripting. Note that it is not comprehensive: there are other alternatives. Refer to Bookshelf, especially the Siebel Applications Administration Guide, for more administrative alternatives.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 8
Copyright © 2009, Oracle. All rights reserved.
Personalization
• Is a framework for customizing Siebel applications for each user– Tracks attributes of users with User Profiles
— User profiles are made up of Profile Attributes
– Stores descriptive information (content tagging) to match with user attributes
– Defines rules to determine which views, applets, and data are shown to a user
– Reacts to the user’s behavior (events) at run time
• Examples: – Show only those articles in a news applet that match the
user’s stated interests
– Display a customized version of an applet for a specific group of users
Siebel Personalization
Reference
Bookshelf’s Siebel Personalization Administration Guide.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 9
Copyright © 2009, Oracle. All rights reserved.
Runtime Events
• Allow an administrator to define a sequence of actions, an action set, to be executed when an application event occurs– Example: Execute a business service method when an
Account business component record is written to the database
Applet
Business Component
Application
Action
Action
UpdateAttribute
Invoke an ObjectMethod
Invoke a Bus. Service Method
Action Sets Action Types
Login
Save Record
Button Click
RuntimeEvents
Runtime Events
Reference
Runtime events are part of Siebel Personalization. The use of runtime events to invoke business service methods is discussed in more detail in a later lesson.Diagram
The picture shows the relationship between Siebel objects (Application, Applet, and Business Component) and action sets, which are composed of one or more actions. Runtime Event Architecture
Siebel runtime events support events on the following object types:• Application (Example: Login, Logoff, etc.)• Applet (Example: Invoke Method, etc.)• Business Component (Example: WriteRecord, DeleteRecord, etc.)
Each event can be associated with an Action Set which contains one or more actions. The following action types are supported:
• Business Service: Invoke a business service method and pass arguments• Set Attribute: Set a Profile Attribute to a specified value• Invoke Method: Invoke a method of the current object. Example: the Business Component
WriteRecord method.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 10
Copyright © 2009, Oracle. All rights reserved.
State Model
• A Siebel state model captures and enforces restrictions on state transitions for a business entity– Defines rules and conditions that specify allowed transitions
– Examples: — Only the manager can change the status of a service request
(SR) record from Open to Cancelled
— A SR must have an owner to be in the Pending state
— Only non-critical SRs can be cancelled
Only permitted if severity <> critical
Only permitted by call center manager
Cancelled
ClosedPendingOpen
Only if owner is assigned
ServiceRequest
State
Siebel State Model
Reference
Siebel State Models is the topic of Bookshelf’s Siebel Applications Administration Guide, "State Models".
DiagramThe flow chart shows the four SR states: Open, Pending, Closed, and Cancelled, as well as the allowed transitions between them. Several of the transitions have conditions imposed on them.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 11
Copyright © 2009, Oracle. All rights reserved.
Data Validation Manager (DVM)
• Comprises the Data Validation Manager business service and a screen for administering validation rules and messages
• Allows:– Defining validation rules in an administration view
– Building complex rules using Siebel Query Language
– Displaying custom error messages
– Logging validation events
Custom error messages
Siebel Data Validation Manager (DVM)
Reference
Data Validation Manager is discussed in Bookshelf’s Siebel Order Management Infrastructure Guide, "Data Validation Manager".
Siebel Query Language
Siebel Query Language is used throughout Siebel applications to construct expressions. Siebel Query Language is used in Siebel Workflow, Siebel DVM, predefined queries, and many other facilities. In addition, Siebel Query Language is used declaratively: to enter conditional properties for object definitions in Siebel Tools. Siebel Query Language syntax and operators are described in appendices to Bookshelf’s Siebel Personalization Administration Guide.
Diagram
The screenshot shows a dialog that displays two error messages. This output is the product of Siebel DVM.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 12
Copyright © 2009, Oracle. All rights reserved.
DVM Examples
• Disallow deletion of a service request when there are pending activities associated with it
• Disable navigation to the next view in a workflow until a specific field has been set
• Notify that an order‘s date is in the past, but allow the user to continue
• Use a workflow to validate records in a batch and inspect the validation log
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 13
Copyright © 2009, Oracle. All rights reserved.
Audit Trail
• Is an administrative facility that creates a history of changes made to Siebel data and captures:– Who accessed the item
– Which operation was performed
– When the operation was performed
– How the item was changed
• Records who viewed or exported data
• Can be set to audit:– Operations (such as read, update, new, delete, and export)
– Operations performed during a specific time
– Operations performed by certain responsibilities, positions, or employees
– Certain fields
Audit Trail
Reference
Bookshelf’s Siebel Applications Administration Guide, "Audit Trail".
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 14
Copyright © 2009, Oracle. All rights reserved.
Audit Trail Example
• Audit Quotes and Opportunities– Track modifications and copies
User session information
Audited data information
Audit Trail Example
Diagram
The screenshot shows audit trial items, which include Quotes and Opportunities. The applet shows the User Id of the employee accessing data, the date, the field involved, operation (modify or copy record), and the values of the field. O
racl
e U
nive
rsity
and
(Ora
cle
Cor
pora
tion)
use
onl
y.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 15
Copyright © 2009, Oracle. All rights reserved.
Assignment Manager
• Allows companies to automatically assign business data to the most appropriate positions, people, and organizations
• Siebel Assignment Manager consists of:– Administrative functionality to define assignment rules
– Server components to automatically assign business data according to the rules
• Assignment Manager examples:– Incoming service requests (SRs) are dynamically assigned to
an agent based on language, product knowledge, and workload
— Assignment rules are used to balance the assignment criteria
– Opportunities resulting from a major trade show are batch assigned to sales reps based on sales territory, industry, and major account status
Siebel Assignment Manager
ReferenceAssignment Manager is documented in Bookshelf’s Siebel Assignment Manager Administration Guide.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 16
Copyright © 2009, Oracle. All rights reserved.
Declaratively-Configured Alternativesto Scripting
• Declarative configuration is used to configure Siebel applications using Siebel Tools– Siebel developers create or modify object definitions that are
used to instantiate objects
– Object definitions consist of name/value pairs called properties
• Declarative configuration requires more effort than an administrative solution, but:– Is easier to maintain and upgrade than script
– Typically performs much better than script
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 17
Copyright © 2009, Oracle. All rights reserved.
Declarative Configuration Examples
• Examples of declarative or Tools based configuration include:– Siebel Workflow
– Siebel Task UI
– Business Component (BC) Field properties— BC Field validation properties
– User Properties
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 18
Copyright © 2009, Oracle. All rights reserved.
Workflow
• A workflow process is an ordered set of steps executed in response to a defined set of conditions
• Siebel Workflow provides:– A set of tools to graphically define workflow processes
– An engine to automate these processes
Workflow processes are
created in Siebel Tools’
Workflow Designer
Siebel Workflow
Siebel Workflow is one of the most commonly-used forms of business automation in Siebel applications. Siebel CRM comes with hundreds of seed workflows that provide the out-of-the-box functionality of modules such as Siebel Marketing, Siebel Customer Order Management, and Siebel Loyalty. Siebel Workflow and Siebel Task UI are a mix of declaratively- and administratively-configured functionality. While workflow processes and tasks are configured in Siebel Tools by developers, they are not compiled into the .srf file. In addition, workflow and task activation and deactivation can be done by application administrators.
Reference
Bookshelf’s Siebel Business Process Framework: Workflow Guide
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 19
Copyright © 2009, Oracle. All rights reserved.
Workflow Example
• When the severity field of a Service Request is set to Critical, then set the SR Priority to ASAP and email key service personnel, such as the Service Center manager– Severity measures the impact of an issue on the service
customer
– Priority reflects the importance attached to the SR
Branch based on SR severity
Workflow Example
Diagram
The workflow process shown checks the severity of a new SR and branches. For most critically severe SRs the workflow sets priority to ASAP and sends an email to the Service Manager, and for lower severity, the priority is set to High. O
racl
e U
nive
rsity
and
(Ora
cle
Cor
pora
tion)
use
onl
y.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 20
Copyright © 2009, Oracle. All rights reserved.
Task UI
• Uses a wizard-like interface to guide users through steps in a task– Consists of a sequenced set of views, each of which collects
a small set of relevant data from the user
• Assists users in navigation and collecting critical business data
User enters only necessary Contact
data and then navigates to next screen with Next
Task pane shows current
position in task
Siebel Task UI
Reference
Bookshelf’s Siebel Business Process Framework: Task UI Guide.
Diagram
The screenshot shows the task navigation pane on the left and a task applet with Pause, Previous (grayed out), Next, and Cancel buttons.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 21
Copyright © 2009, Oracle. All rights reserved.
Tasks
• Display a sequence of views to users– Views are typically simplified to only display required
information
• Enable users to create and modify records
• May contain conditional logic
• Allow users to pause task execution and resume later– Intermediate results are saved when a task is paused
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 22
Copyright © 2009, Oracle. All rights reserved.
Business Component Field Properties
• Fields can be configured in Siebel Tools to implement business logic using field properties
BC Field properties for Opportunity BC,
Name field
Opportunity Name is a required field
Business Component Field Properties
Screenshot
The diagram shows Siebel Tools’ Properties Window for a BC field.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 23
Copyright © 2009, Oracle. All rights reserved.
Business Component Field Properties
• Business component field properties include:– Required: the user must provide a value for the field
– Read Only: the field cannot be changed by a user
– Force Case: force upper, lower, or first letter in upper case
– Pre Default Value: populate with a default value before displaying a new record
– Post Default Value: populate with a default value if user does not provide one prior to saving
– Calculated Value: calculate a value based on values of other fields
– Validation and Validation Message: see next slide
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 24
Copyright © 2009, Oracle. All rights reserved.
BC Field Validation Properties
• Business component field properties that can be used to validate entered field values are:– Validation: an expression that evaluates to False when the
field value is invalid
– Validation Message: text that is displayed on a validation error
Field nameValidation
criteriaValidation error
message
Example: Discount % field must be
between 0 and 100
BC Field Validation Properties
Reference
BC Field Properties are documented in the Siebel Object Types Reference.
Validation Techniques
Both DVM and BC field validation properties can be used to validate data. DVM is more flexible, as validation rules can be changed at runtime by an administrator, while BC Field validation properties are changed by a developer, and a new .srf must be distributed. However, BC Field properties are faster and are more suitable for validating fields whose validation criteria will not change.
Diagram
The screenshot shows validation properties for business component fields. For example, the Discount % field has a validation property of ">=0 AND <=100", as well as a validation message of "Invaliddiscount %". This message will be displayed if the Discount % value violates the validation condition.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 25
Copyright © 2009, Oracle. All rights reserved.
User Properties
• Are child object definitions added to several UI and business layer object definitions– Configure specialized behavior beyond what is configured in
the parent object definition’s properties
– Are stored in the repository and are compiled into the repository file
– Are passed to the C++ code that implements the class— Values can be edited or created to modify the existing behavior
BC user property is a child object
type of BC
User Properties
ReferenceBookshelf’s Configuring Siebel Business Applications, "Configuring Business Components"
Object Types Supported
Object types with user properties defined are:• Applet• Application• Business Component• Control• Field• List Column• View
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 26
Copyright © 2009, Oracle. All rights reserved.
Business Component User Property Example: On Field Update Set
• Updates a single value field when another field is updated– Value property consists of:
— The field to check
— The field to update
— A value or expression to set (defaults to the value in the checked field)
Sets Contact to "" when Agreement is updated
On Field Update Set
Condition Parameter
The value property may also include an optional fourth parameter which serves as a condition. If the Condition parameter is defined, then the "field to update" is updated only if the condition evaluates to TRUE.
Diagram
The screenshot shows an On Field Update Set user property that will cause the Contact field for a Service Agreement to be cleared when the Agreement is updated.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 27
Copyright © 2009, Oracle. All rights reserved.
Review: Finding Alternatives to Scripting
• Recommended Approach: minimize the level of effort in finding a scripting alternative
Requirement
SupportedAs-Delivered?
Use an as-deliveredsolution
AdministrativeSolution?
Usean administrative
solution
DeclarativeSolution?
Use a declarative
Solution
Write a goodscript
Level of effort / RiskLow High
Yes Yes Yes
No No No
Review: Finding Alternatives to Scripting
Diagram
The flowchart shows a way of meeting application requirements with the lowest level of effort and risk. First, determine if the as-is application offers desired functionality, and if so, use thisfunctionality. If not, determine if there is an administratively-configured solution, and if so, use it. If not, then evaluate a declarative solution. Only if these alternatives are unavailable should you write a script. The rest of this course is on how to right correct scripts.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 28
Copyright © 2009, Oracle. All rights reserved.
Lesson Highlights
• Alternatives to scripting can be categorized:– As-delivered functionality: no additional configuration
required— Example: export Account data to a file
– Administrative functionality: configure using the Siebel client
– Declarative configuration:— Use Siebel Tools to create or modify object definitions
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 2 - 29
Copyright © 2009, Oracle. All rights reserved.
Practice 2 Overview: Exploring Validation Methods
This practice covers the following topics:
• Use Siebel Data Validation Manager in a workflow
• Set BC field validation properties
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Copyright © 2009, Oracle. All rights reserved.
Siebel Event Handling
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 3 - 2
Copyright © 2009, Oracle. All rights reserved.
Lesson Objectives
• After completing this lesson, you should be able to:– Describe event handling in Siebel applications
– Identify scriptable objects and their scriptable events
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 3 - 3
Copyright © 2009, Oracle. All rights reserved.
Siebel Events
• An event represents a user or system action that occurs while the Siebel application is running
• Siebel applications execute code to handle some events:– An application object manager (AOM) handles events that
occur in user sessions
– Other server components may handle events— Example: events occurring in some workflow processes are
handled by the Workflow Process Manager component
• Event examples: – User moves from first record to the record in an applet
– An activity record is created in a workflow process
An event occurs when a user moves to the next record
Siebel Events
Siebel Workflow and Events
Siebel workflow processes are executed by either the AOM or by a dedicated server component, Workflow Process Manager. For details on Siebel Workflow execution and architecture, refer to Bookshelf’s Siebel Business Process Framework: Workflow Guide, "Workflow Process Architecture".
Reference
Siebel events and their relationship to scripting is discussed in Bookshelf’s Siebel Object Interfaces Reference.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 3 - 4
Copyright © 2009, Oracle. All rights reserved.
Events and Objects
• When a user is using the Siebel application, instances of Siebel objects are loaded into memory as needed
• Each event is associated with an object type and instance– Event examples:
— Applet ChangeRecord : the user moves to a different record
— Business Component NewRecord : a new record is created
— Application Close event: a user closes the application
View (Account Detail Contacts View)
Applet (Account Entry Applet)
Applet (Account Contact
List Applet)
Business Object (Account)
Business Component
(Account)
BusinessComponent
(Contact)
Events and Objects
Example
The diagram on this slide shows object instances associated with the current view in a user session. Both user interface (UI) and business layer object instances are created to support the user session. The UI layer object instances shown are: one view instance and two applet instances. Underlying business layer object instances corresponding to those UI objects are shown as well. O
racl
e U
nive
rsity
and
(Ora
cle
Cor
pora
tion)
use
onl
y.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 3 - 5
Copyright © 2009, Oracle. All rights reserved.
Events and Scripting
• Siebel applications provide developers with application programming interfaces (APIs) to add user-defined scripts to an object definition– A script is a child object
• The script extends the standard Siebel-installed event handler– Example: When the user moves to the next record, a script
added to the Quote List Applet will run
User code runs as part of Applet ChangeRecord event
handler
Script is attached to Quote List Applet object definition
Applet events
Events and Scripting
Diagram
The diagram shows how events appear in the Siebel Script Editor. Events for an object appear below the object in the navigation pane, and the code for an event handler appears in the main code pane when the handler is selected in the navigation pane. The tab title in Siebel Tools gives the object type, BrowserApplet in this diagram, and the object’s name. O
racl
e U
nive
rsity
and
(Ora
cle
Cor
pora
tion)
use
onl
y.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 3 - 6
Copyright © 2009, Oracle. All rights reserved.
Pre- and Post-Event Handlers
• When an event occurs, the Siebel application executes:– A pre-operation handler defined for the object instance
— The event name starts with "Pre"
– The standard handler to perform the event action— This handler, typically written in C++, cannot be modified
— Example: Change the current record in an applet
– A post-operation handler defined for the object instance— The event name does not start with "Post"
• Important note: not all events have a pre and post handlerRun "pre" event handler
Run "post" event handler
Perform standard handlerEvent
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 3 - 7
Copyright © 2009, Oracle. All rights reserved.
Scripting Pre- and Post-Event Handlers
• Write script for a pre-event handler to customize application behavior before execution of the standard Siebel operation– Example: Script the BusComp_PreWriteRecord event for the
Opportunity BC to execute a script before an Opportunity record is written
— Can be used for validation
• Write script for a post-event handler to customize application behavior after execution of the standard Siebel operation– Example: Script the BusComp_DeleteRecord event for the
Opportunity BC to execute code after an Account is deleted— Can be used to perform user-specific "cleanup" after BC
deletion
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 3 - 8
Copyright © 2009, Oracle. All rights reserved.
Avoiding the Siebel-Installed Event Handler
• A user-scripted pre-event handler can either:– Allow the standard Siebel event handler to proceed by
returning ContinueOperation
– Bypass execution of the standard handler (and any post-event handler) by returning CancelOperation
— Example: If validation fails in BusComp_PreWriteRecord, abort writing the record
Run "pre" event handler
Run "post" event handler
Perform standard handler
ContinueOperationCancelOperation
Avoiding the Siebel-Installed Event Handler
Event Handler Return Values
CancelOperation and ContinueOperation are defined constant values that you can return in your script code.
Undefined or Error-producing "Standard" Event Handlers
For some object/event combinations there is no defined Siebel handler or the Siebel handler creates an error message. One example that will be discussed in a later lesson is the standard, Siebel-installed handler for invoking a business service. If the Siebel handler does not recognize the business service (which it won’t for a custom-defined business service), then the handler will report an error. In such cases, a scripted handler should return CancelOperation on successful completion to avoid the standard Siebel handler.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 3 - 9
Copyright © 2009, Oracle. All rights reserved.
Siebel Object Interfaces
• Siebel Object Interfaces provides APIs for scripting object events and object methods
• These APIs are documented in:– Bookshelf’s Siebel Object Interfaces Reference– Siebel Tools’ online help
Online help in Siebel Tools
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 3 - 10
Copyright © 2009, Oracle. All rights reserved.
Siebel Object Interfaces:Event Handlers for Scripting
• The Siebel Object Interfaces APIs provide event handlers for the following object types:– Application
– Applet
– Business Component
– Business Service
Siebel Object Interfaces: Event Handlers for Scripting
The events for the different object types can be categorized in general terms:• Application event handlers mostly relate to a user’s session, including Application_Start
(login), Application_Stop (logout), and Application_Navigate (navigation).• Applet event handlers relate to changes in the user interface (UI), including Applet_Load (load
applet), Applet_ChangeField (a UI field changes), and Applet_ChangeRecord (change records in the UI).
• Business component (BC) event handlers relate to changes in data, such as BusComp_DeleteRecord, BusComp_Query, and BusComp_WriteRecord.
• Business service event handlers relate to method invocation. These handlers are covered in detail in an upcoming lesson.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 3 - 11
Copyright © 2009, Oracle. All rights reserved.
function BusComp_PreSetFieldValue (FieldName, FieldValue)
{
// user the GetFieldValue method to retrive the previous value
var prev = this.GetFieldValue(FieldName);
// Do something with the previous value
. . .
return(ContinueOperation);
}
Object Methods
• A method is a named routine that can be called in an event handler script, to get an object instance to do something– Method example: Use the business component
GetFieldValue() method to read the previous field value in the BusComp_PreSetFieldValue event handler
Object Methods
The term "method" is overloaded in Siebel. It refers to:• A named routine as defined on this slide,• A business service child object, or• A function offered by a business service.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 3 - 12
Copyright © 2009, Oracle. All rights reserved.
Siebel Object Interfaces:Object Methods for Scripting
• The Siebel Object Interface APIs provide scripting methods for the following object types:– Application
– Business Object
– Business Component
– Applet
– Business Service
– Property Set
– Control (browser script only)
Siebel Object Interfaces: Object Methods for Scripting
This slide refers to object methods, not the event handlers that were mentioned in a previous slide.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 3 - 13
Copyright © 2009, Oracle. All rights reserved.
Run-Time Events and Scripted Event Handling
• Run-time events provide an administrative solution to associate actions with an event– Discussed in a previous lesson
• Actions for a run-time event execute before a scripted pre-event handler
Run "pre" event handler
Run "post" event handler
Perform standard handlerEvent
Perform actions for run-time event
Scripted pre-event handler
Run-Time Events and Scripted Event Handlers
Example
We define an action set for the Opportunity BC WriteRecord run-time event. In addition, we have created a script for the Opportunity BusComp_PreWriteRecord event handler and the Opportunity BusComp_WriteRecord event handler. When an Opportunity record is written, the following sequence of handlers executes:
• The action set for the WriteRecord run-time event• The BusComp_PreWriteRecord scripted event handler• The Siebel-installed event handler, which writes the Opportunity record• The BusComp_WriteRecord scripted post-event handler
Run-Time Events Reference
Run-time events are covered in Bookshelf’s Siebel Personalization Administration Guide.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 3 - 14
Copyright © 2009, Oracle. All rights reserved.
Complex Event Handling Example:What Happens on a Button Click?
1. Button click
3. If not cancelled in the browser, the method is invoked on the server-side instances of applet
and business component
4. Siebel standard methods are
implemented in C++ classes
5. Post-operation event handlers on
business components and
applets
6. Post-operation browser script can
execute2. Pre-operation browser script can execute
A Complex Event Handling Example: What Happens on a Button Click?
The diagram explains the sequence of event handlers that are called when a method is invoked in the Siebel High-Interactivity framework. Methods can be invoked in various ways such as a button click. Not all of these event handlers will run for any specific button click: instead, this slide highlights the relative ordering of handler execution.
Note that in the pre-branch, the runtime event action sets are triggered before the server scripts. In the post-branch, you can also define the Named Method user property for additional processing.Both runtime events and user properties were discussed in the lesson on scripting alternatives.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 3 - 15
Copyright © 2009, Oracle. All rights reserved.
Identifying the Correct Event Handler
• Choosing the correct event handler for scripting is important because it influences the application’s:– Performance
– Code manageability
– Upgradeability
• Recommended approach: during development, add test code to an event handler to find when it is executed– Use Trace methods to log when the handler is executed
– Best practice: Avoid scripting event handlers that run very often
— Example: The PreGetFieldValue event handler is executed for each field of a record
Identifying the Correct Event Handler
Practice
In the practice for this lesson, you will trace event handler execution in a complex example.
Trace Methods
The Application methods TraceOn(), Trace(), and TraceOff() are discussed in an upcoming lesson. These methods allow you to log data within a script.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 3 - 16
Copyright © 2009, Oracle. All rights reserved.
Choosing the Correct Handler
• To identify the correct handler to script, answer the following questions:– Should the event be handled in a pre- or post-event handler?
— Should the Siebel handler run before your script?
– Should the event be handled at the user interface (UI) layer or at the business layer?
— Example: an Applet script can only run in views that display theapplet, while a Business Component (BC) script can be executed in any view that displays the BC
– Should the event be handled in a browser script or in a server script?
— The differences between browser and server scripts are covered in later lessons
– Which specific event is being handled?— Example: BC handlers WriteRecord versus NewRecord
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 3 - 17
Copyright © 2009, Oracle. All rights reserved.
Lesson Highlights
• An event is a user or system action that occurs while the Siebel application is running– The application will execute a "standard" event handler in
response
– An event is associated with an object type and instance
• Customize application behavior by scripting:– A pre-event handler that runs before the standard event
handler
– A post-event handler that runs after the standard event handler
• A pre-event handler can end an event’s processing by returning CancelOperation
• The Siebel Object Interfaces APIs expose object events and methods for use in scripts
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 3 - 18
Copyright © 2009, Oracle. All rights reserved.
Practice 3 Overview: Exploring Siebel Events
This practice covers the following topics:
• Execute scripted event handlers
• Trace handlers that are executed in response to an event
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Copyright © 2009, Oracle. All rights reserved.
Coding and Debugging in theSiebel Tools Script Editor
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 2
Copyright © 2009, Oracle. All rights reserved.
Objectives
After completing this lesson, you should be able to:
• Use Siebel Tools’ script editor to create or modify scripts
• Set scripting options in Siebel Tools
• Compile scripts
• Use the Siebel Tools script debugger
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 3
Copyright © 2009, Oracle. All rights reserved.
Siebel Tools’ Script Editor
• Is used to create and modify scripts:– Browser scripts (JavaScript)– Server scripts (eScript and Siebel VB)
Siebel Tools’ Script Editor
Siebel Tools’ scripting tools, including the script editor, are documented in Bookshelf’s Using Siebel Tools.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 4
Copyright © 2009, Oracle. All rights reserved.
Opening the Script Editor
• To open the script editor:– Select View > Editors > Server Script Editor or Browser
Script Editor, or
– Right-click a scriptable object definition in the Object List Editor and select Edit Server Scripts or Edit Browser Scripts
Right-click a scriptable object to get this menuSelect View > Editors >
Server Script Editor or Browser Script Editor
Opening the Script Editor
Make sure the project containing the object being modified is checked out or locked, otherwise the script that appears in the editor is read-only.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 5
Copyright © 2009, Oracle. All rights reserved.
Selecting a Server Scripting Language
• When you open a server script, select the language from the Scripting Language dialog:– eScript or Siebel Visual Basic (Siebel VB)
This dialog only appears for the
first script written for an object
Selecting a Server Scripting Language
No such dialog appears for browser scripts, as only JavaScript is supported for them.You can select a default scripting language for server scripts in View > Options > Scripting or by checking a box on the Scripting Language dialog (covered by the dropdown list in the screenshot above). O
racl
e U
nive
rsity
and
(Ora
cle
Cor
pora
tion)
use
onl
y.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 6
Copyright © 2009, Oracle. All rights reserved.
Parts of the Script Editor
• The script editor has several important parts:– Navigation pane: allows quick access to functions and object
event handlers
– Code pane: presents code editor with syntax highlighting
– Toolbars: support compilation, debugging, and profiling
Navigation pane
Code pane
Toolbars
Parts of the Script Editor
Diagram
The diagram shows the Script Editor navigation pane on the left side, the main code pane on the right, and the toolbars on top.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 7
Copyright © 2009, Oracle. All rights reserved.
Using the Navigation Pane
• The editor navigation pane has two top-level headings:– (general) contains object-scope variable declarations and
custom functions
– Object Type contains event handlers defined for the object type
— Example: For a business service script object, the heading would be Service, and it would contain all event handlers for the Business Service type
Object-scope variable declarations and custom functions
Business service event handlers
Using the Navigation Pane
The diagram shows both object-scope functions and business service event handlers in the navigation pane. The navigation pane displays a very useful visual cue: notice how the Service_PreCanInvokeMethod handler appears next to a grayed-out icon, which indicates that this handler is not defined. Some object types, such as Business Component, have many possible handlers, and being able to quickly identify which are scripted is very helpful. O
racl
e U
nive
rsity
and
(Ora
cle
Cor
pora
tion)
use
onl
y.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 8
Copyright © 2009, Oracle. All rights reserved.
Entering Code
• A newly-created script object includes stubs for the parent object type’s event handlers
• Add new code to the provided function stubs– Unused stub code does not incur any runtime overhead
Event handler stub code is produced when the script object is created
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 9
Copyright © 2009, Oracle. All rights reserved.
Importing and Exporting Scripts
• Select File > Import to import code into the Siebel Tools script editor
• Select File > Export to save script to a file– Uses .js extension for eScript and JavaScript and .sbl for
Siebel VB
Import Script dialog
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 10
Copyright © 2009, Oracle. All rights reserved.
Setting Scripting Options
• Select View > Options and click the Scripting tab to set scripting options in Siebel Tools
View > Options opens this window
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 11
Copyright © 2009, Oracle. All rights reserved.
ScriptAssist
• Refers to features in the Siebel Tools script editor that take advantage of the eScript ST syntax features
• These features:– Speed up script
development
– Help create more manageable code
• The ST eScript engine must be enabled to set ScriptAssist options
Script Assist
The Siebel eScript ST scripting engine was introduced in Siebel 7.8. Enable the ST engine by setting the system preference Enable ST Script Engine to TRUE.
Engine Settings
The three checkboxes shown at the bottom right of the highlighted section control scripting engine behavior:
• Fix and Go allows quick development-test-fix cycles. This feature is covered later in this lesson.
• Enable Warnings will cause the engine to display compilation warning messages• Deduce Types allows the scripting engine to deduce local variable types by examining the data
that is assigned to these variables. This process isn’t always possible, but when types can be deduced, the interpreted code is more compact and performs better. Type deduction is not a complete substitute for using strong variable typing, which is highly recommended.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 12
Copyright © 2009, Oracle. All rights reserved.
ScriptAssist Features
• Method Listing – displays available object methods and properties
• Auto-complete – allows quick completion of a method or property name based on selection in drop-down list
• Tool Tips – gives return type, arguments, and method summary
Enter a typed variable name and
a period …
Tool Tips show the prototype for
the selected method
Method Listing shows methods
available for oBC
Auto-complete fills in the selected
method when you type TAB
ScriptAssist Features
Diagram
The screenshot illustrates ScriptAssist features:• Method Listing displays a drop-down list populated with available methods for an object• Tool Tips show prototypes for methods• Auto-complete will enter a method name when the developer types TAB. O
racl
e U
nive
rsity
and
(Ora
cle
Cor
pora
tion)
use
onl
y.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 13
Copyright © 2009, Oracle. All rights reserved.
ScriptAssist Repository Introspection
• The Siebel Tools script editor is aware of repository information– Referred to as Repository Introspection
– The script editor is aware of relationships between object instances
– Repository information is used by Method Listing, Auto-Complete, and Tool Tips
• Example: Child business components of the Users business object
Editor is aware of child business components of the
Users business object
ScriptAssist Repository Introspection
Diagram
The diagram shows that once the variable oBO has been bound to the Users business object, then the Script Editor is able to use repository information to present a selection of child business components for the Users business object.
Another Example
Another example of repository introspection is seen with the Business Component method ActivateField(), which is used to prepare for query execution. After you type "BCVar.ActivateField(", the script editor will present a drop down showing business component field names.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 14
Copyright © 2009, Oracle. All rights reserved.
Favorites
• The most frequently accessed methods listed in the ScriptAssist window appear at the top– Favorites appear in italic type
– Session-based
– Unused favorites eventually drop from favorites
• Turn on this option in the View > Options > Scripting dialog box
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 15
Copyright © 2009, Oracle. All rights reserved.
Favorites – Example
Recently used methods appear
first
Only methods and properties for
TheApplication appear in the method listing
Method listing appears when
you type a variable name followed by a
period
Favorites - Example
Diagram
The screenshot shows how the most recently called methods appear at the top of the method listing box.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 16
Copyright © 2009, Oracle. All rights reserved.
Compiling Script Object Definitions
• When code is saved in the Script Editor the scripting engine performs a syntax check– Use the Enable Warnings flag to generate syntax warnings
• Compile the scripted object’s project or the scripted object– Object definitions are stored in the .srf file
Syntax check flags possibly incorrect code
Compiling Script Object Definitions
In the example shown, the business component method ExecuteQuery() takes an optional parameter, cursorMode. The warning message presents useful information, but may be safely disregarded in this example
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 17
Copyright © 2009, Oracle. All rights reserved.
• You must generate and distribute JavaScript files for browser scripts
• For the Mobile or Developer Web Client, files are under <client_root>\PUBLIC\language_code– Example: D:\OUsea\Client\PUBLIC\enu
• For Web client, files are under <server_root>\WEBMASTER– Example: D:\OUsea\siebsrvr\WEBMASTER
– You must upload these files to the Web server
Compiling Browser Scripts
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 18
Copyright © 2009, Oracle. All rights reserved.
Setting the Browser Script Compilation Folder
• Specify the browser script compilation folder in the Tools configuration dialog– During compilation, Siebel Tools extracts all browser scripts
to subfolders in this folder
– Subfolder names include a repository version number
Folders contain compiled
browser scripts
Setting the Browser Script Compilation Folder
A second way to set the browser script compilation folder and generate browser scripts is to use the genbscript.exe utility. This command-line utility takes an application’s .cfg file and the browser script compilation directory as arguments and generates browser scripts for all such scripts in the repository. For more details on genbscript.exe, see the Bookshelf title Configuring Siebel Business Applications. O
racl
e U
nive
rsity
and
(Ora
cle
Cor
pora
tion)
use
onl
y.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 19
Copyright © 2009, Oracle. All rights reserved.
• When using the Web client, refresh the Web servers after compiling browser scripts
• Two ways to refresh:– Manually restart the Web server
– Use the Siebel Web Engine to upload files to the Web server — Preferred because it is less invasive
— Use the UpdateWebImages SWE command
Updating Browser Scripts for the Siebel Web Client
Start Siebel Call Center while refreshing the
Web server
Updating Browser Scripts for the Siebel Web Client
Diagram
The picture shows a browser Address field filled in with the address:http://webserver/callcenter_enu/start.swe?SWECmd=UpdateWebImages&SWEPassword=eapps_password O
racl
e U
nive
rsity
and
(Ora
cle
Cor
pora
tion)
use
onl
y.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 20
Copyright © 2009, Oracle. All rights reserved.
Siebel Script Debugger
• The Siebel Tools scripting environment provides debugging features:– Setting and clearing breakpoints
– Controlling code execution
– Watching variables
– Tracing the function call sequence
• Access debugger functionality from the Debug menu and toolbars
Debug and Profiler toolbars
Debug menu
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 21
Copyright © 2009, Oracle. All rights reserved.
Setting Debugger Options
• The debugger is synchronized with a Siebel Developer Web Client, which runs the script being debugged
• Debug functions control code execution in the Siebel client– Example: breakpoints
• Specify client startup parameters in the View > Options > Debug pane
/h starts the client in Debug mode
Setting Debugger Options
Debug Mode
In Debug mode, the Siebel client displays detailed debugging information when it encounters a run-time error. Also, the Script Profiler, covered in an upcoming lesson, gathers performance data in Debug mode.Browser Executable
If you leave the Browser executable path blank, the client will start up using the default browser.Arguments
The argument field is used to pass switches to the client executable. Switches are:/c Path to .cfg file (required), directory path defaults to <client_installdir>\bin\enu/d Datasource (as in .cfg file), defaults to local/l language (optional, language pack must be installed), defaults to enu/u Username (optional)/p Password (optional)/s Path to spool file (optional, to spool all SQL generated by siebel.exe)/b Path to Browser executable (optional, for multi-browser testing of customer or partner (SI)
applications)/h Debug Mode (used with Siebel Tools for debugging)
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 22
Copyright © 2009, Oracle. All rights reserved.
Setting a Breakpoint
• A breakpoint stops script execution at a specified code line– Click the line of code where a breakpoint is desired
– From Debug menu or toolbar, select Toggle Breakpoint
Toggle breakpointToggle breakpoint Red shading and circle indicates breakpoint
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 23
Copyright © 2009, Oracle. All rights reserved.
Starting the Debugger
• In Siebel Tools, select Debug > Start or use the Debug toolbar
• A new run-time instance of the client application starts
Siebel Client
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 24
Copyright © 2009, Oracle. All rights reserved.
Triggering a Breakpoint
• Go to the appropriate view in the application
• Perform an action to trigger code you wish to debug– When execution reaches a breakpoint, application execution
is suspended
• Control is transferred back to Siebel Tools– Blue band appears where execution stopped
Script execution is stopped before this
instruction
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 25
Copyright © 2009, Oracle. All rights reserved.
Resuming from a Breakpoint
• The script debugger allows you to control script execution from a breakpoint
• Use the Debug menu to:– Continue until the next breakpoint
– End execution
– Step into function calls
– Step over calls, staying in the currentscope
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 26
Copyright © 2009, Oracle. All rights reserved.
Monitoring Script Variables in the Watch Window
• While script execution is paused at a breakpoint, monitor variable values by opening the Watch window– Open with View > Debug
Windows > Watch or from the Debug toolbar
Open Watch window
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 27
Copyright © 2009, Oracle. All rights reserved.
Tracing the Function Call Hierarchy
• While script execution is paused at a breakpoint, track the sequence of function calls in the Calls window– Open with View > Debug Windows > Calls or from the Debug
toolbar
The initial procedure called is at the bottom of the call list
Tracing the Function Call Hierarchy
Note that the Script Calls window displays the current line number, which is where execution hit the breakpoint.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 28
Copyright © 2009, Oracle. All rights reserved.
• No need to close client for compilation
• Start compilation in Siebel Tools– Object compile (CTRL+F7)
– Project compile (F7)
• All running clients currently using the target .srf suspend automatically– System tray icon changes from red to gray
– siebel.exe remains in memory
• After compilation, clients are restarted– Restart is faster, due to information already in memory
• Clients automatically navigate to the last-visited view– No need to repeat complex navigation
Rapid Unit Testing
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 29
Copyright © 2009, Oracle. All rights reserved.
Fix and Go
• Allows changing a script in Siebel Tools and testing on the Siebel client without closing the client or recompiling– Available for server scripts written in eScript using the
eScript ST scripting engine
– Enable Fix and Go in the Edit > Options > Scripting dialog
• To use Fix and Go:1. Compile the script once
2. Open the client and test the script
3. Modify the script
4. Use Save or Save all in the script editor
5. Test the modified script
6. Save and compile script before exiting Tools
Repeat as necessary
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 30
Copyright © 2009, Oracle. All rights reserved.
Lesson Highlights
• Siebel Tools provides debugging support– The script debugger supports common debugger functions
– Script Assist features are repository-aware and offer:— Method Listing
— Quick Complete
— Tool Tips
• Set scripting options in the View > Options > Scripting tab
• Set debugging options in the View > Options > Debug tab– Control script execution using breakpoints
• Important tools for verifying the correctness and performance of scripts are:– The watch window
– The hierarchical calls window
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 4 - 31
Copyright © 2009, Oracle. All rights reserved.
Practice 4 Overview: Exploring the Siebel Tools Scripting Environment
This practice covers the following topics:
• Examine a server script using the Siebel Tools scripting editor
• Use script editor features to modify code
• Debug a script
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Copyright © 2009, Oracle. All rights reserved.
Scripting Using the Siebel Object Interfaces
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 2
Copyright © 2009, Oracle. All rights reserved.
Objectives
After completing this lesson, you should be able to:
• Describe the Siebel Object Interfaces
• Code common operations in eScript using the Siebel Object Interfaces
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 3
Copyright © 2009, Oracle. All rights reserved.
The Siebel Object Interfaces
• Siebel Object Interfaces provides application programming interfaces (APIs) for scripting object event handlers and methods– The exposed event handlers are used to specify when your
script will execute— Pre- vs. post-event handlers
– The exposed object methods are used to specify how your script is implemented
The Siebel Object Interfaces
Reference
The Siebel Object Interfaces are documented in Bookshelf‘s Siebel Object Interfaces Reference.
Other APIs in the Siebel Object Interfaces
The Siebel Object Interfaces also support integrating with external applications using:• The Siebel Component Object Model (COM) APIs• Java with the Siebel Java Data Beans API
Component Object Model (COM) is a standard for software interprocess communications and object creation. The original COM standard was developed by Microsoft, and the standard is primarily used with Microsoft Windows. These APIs are documented in Bookshelf‘s Siebel Object Interfaces Reference. This course will not cover them in detail, as these APIs are primarily concerned with application integration.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 4
Copyright © 2009, Oracle. All rights reserved.
Siebel Object Interfaces:Event Handlers for Scripting
• The Siebel Object Interfaces APIs allow you to script events for the following object types:– Application
– Applet
– Business Component
– Business Service
• The exposed event handlers allow you to script a pre-event handler, a post-event handler, or both– The handlers exposed depends on the object type and event
– Event examples:— The Applet ChangeRecord event only allows post-event
handling
— The Application Navigate event allows both pre- and post-event handling
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 5
Copyright © 2009, Oracle. All rights reserved.
Using the Object Event Handling APIs
• To script a pre- or post-event handler for an object:– Add a server or browser script object to the object definition
in Siebel Tools— Right-click the object definition and select Edit Browser Script or
Edit Server Script
— For server scripts, select eScript or Siebel VB
– Add the event handling script to the event handler stubs provided
Add your event handling script to
the provided function stub
Input arguments and return values for handlers vary,
depending on the event
Exposed handlers for Application objects
Using the Object Event Handling APIs
Entering Handler Code
Not all of the code to support event handling needs to be entered directly into the event handler function. For more modular or maintainable code, you may wish to define functions outside of the event handler function and then call these function in the event handler. For example, within the Application_PreNavigate() function shown, you could call a function named LogNavigationEvents(), that you scripted. To create this function, you would click (general) in the Script Editor navigation pane, and then enter the function body:
function LogNavigationEvents (DestViewName, logFileName, …)
{
/*function body */}
This function would then be callable in the event handler.
Event Handler Arguments
An event handler will be passed arguments that are relevant to handling the event. In the example shown, the Application_PreNavigate handler is passed the destination view name and business object. Refer to the documentation for the arguments for other event handlers.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 6
Copyright © 2009, Oracle. All rights reserved.
Siebel Object Interfaces:Object Methods for Scripting
• The Siebel Object Interface APIs provide methods for the following object types:
SetValue(controlValue)Control
GetProperty(propertyName)Property Set
FindControl(controlName)Applet
InvokeMethod(methodName, inputArgs, outputArgs)
Business Service
Business Component
Business Object
Application
Object Type
GetService(serviceName)
SetFieldValue(fieldName,value)
GetBusComp(BCName)
Example Method
Siebel Object Interfaces: Object Methods for Scripting
The table shows the object types: Application, Applet, Business Object, Business Component, Business Service, Property Set, and Control with sample methods.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 7
Copyright © 2009, Oracle. All rights reserved.
Scripting Examples Usingthe Siebel Object Interfaces APIs
• The following examples illustrate how to use the Siebel Object Interfaces eScript APIs to solve specific problems:1. Creating a property set
2. Calling a business service method
3. Performing a query
Object Method Examples
These examples are not comprehensive: they do not show all of the object types or methods available in the Siebel Object Interfaces APIs. However, the examples show solutions to typical scripting problems, using Siebel object methods.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 8
Copyright © 2009, Oracle. All rights reserved.
Example 1: Creating a Property Set
• A property set is a collection of name-value pairs
• Property sets are used as input and output arguments to business services– If a business service method requires one or multiple input
values, then they are packed into a single property set, which is passed to the business service
– One or more output arguments may be returned from a business service method in the single output property set
• To create and initialize a property set in a script:– Declare a Property Set variable
– Instantiate the Property Set by calling the Application method NewPropertySet()
– Call the SetProperty() method for the Property Set object for each name-value pair
Example 1: Creating a Property Set
Another related example is how to use the output property set returned from a business service method. To unpack the output property set, call the Property Set method GetProperty() for each output name-value pair.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 9
Copyright © 2009, Oracle. All rights reserved.
Example 1: eScript Code
• The following code adds two name value pairs to iPS, a newly-created property set:– The final property set is { ("Arg1", 2.0), ("Arg2", 5.6)}
// Declare and instantiate a Property Set variable
var iPS : PropertySet;
iPS = TheApplication().NewPropertySet();
// Instantiate and initialize variables containing property values
var Arg1 : float = 2.0;
var Arg2 : float = 5.6;
// Add name-value pairs to the property set
iPS.SetProperty("Arg1", Arg1); //name-value pair: "Arg1", 2.0
iPS.SetProperty("Arg2", Arg2); //name-value pair: "Arg2", 5.6
Example 1: eScript Code
The line showing the instantiation of the property set includes the syntactic device TheApplication(), which acts very much like the "this" reference seen earlier in this lesson. TheApplication() is a reference to the current application.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 10
Copyright © 2009, Oracle. All rights reserved.
Example 2: Calling a Business Service Methodin a Script
• To call a business service method programmatically:– Declare a Service object variable
– Instantiate this variable by calling the Application method GetService()
– Create and initialize variables to use as business service method arguments
— Create input and output property sets (see Example 1)
– Call the Business Service method InvokeMethod()
Example 1: Calling a Business Service Method in a Script
Object creation, as shown in this example, is discussed in more depth in a future lesson. Writing custom business services and other methods for invoking business services are also the topics of future lessons.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 11
Copyright © 2009, Oracle. All rights reserved.
Example 2: eScript Code
• The following code excerpt invokes the Multiply method of the SCR Calculator business service– Passes input arguments of 2.0 and 5.6
// Declare a variable for the business service instancevar oBS : Service;
// Instantiate a business service objectoBS = TheApplication().GetService("SCR Calculator");
// Instantiate and initialize input and output argsvar Arg1 : float = 2.0;var Arg2 : float = 5.6;var Result : float;
// Create input and output property sets - See Example 1// Input property set is iPS, output property set is oPS
// Invoke the multiply MethodoBS.InvokeMethod("Multiply", iPS, oPS);
Example 2: eScript Code
Creating the Property Sets
This example omits the steps to create the input and output property sets that are required as arguments to the InvokeMethod() business service method. Creating a property set was covered in Example 1 in this lesson. The input property set is created by a call to the Application method NewPropertySet(), which is then initialized as in example 1.TheApplication()
This syntactic device refers to the current application.Example Code Conventions
This code uses commonly seen Siebel coding conventions for variable names. The "o" in "oBS" suggests that the variable refers to an object, rather than a primitive type, such as a number or a character string. Similarly, for "iPS" and "oPS", where the different prefixes suggest that the former is the input property set, while the latter is the output property set.Script Libraries
Script libraries, discussed in a future lesson, allow you to invoke a business service method differently.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 12
Copyright © 2009, Oracle. All rights reserved.
Example 3: Performing a Query
• To perform a query programmatically:A. Instantiate the queried business object (BO)
B. Instantiate the queried business component (BC)
C. Set the query view mode
D. Activate fields for the query
E. Set the query search specification
F. Execute the query
G. Use the query result set
H. Destroy object instances
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 13
Copyright © 2009, Oracle. All rights reserved.
Example 3A and 3B: Instantiate the Queried BO and BC
• Declare and create the BO to query:– Declare as type BusObject
– Call the Application GetBusObject() method to instantiate
• Declare and create the BC to query:– Declare as type BusComp
– Call the BO GetBusComp() method to instantiate
• Example: Create BO and BC instances for the Account BO and its Account BC
// Create business object and business component objects
var oBO : BusObject = TheApplication().GetBusObject("Account");
var oBC : BusComp = oBO.GetBusComp("Account");
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 14
Copyright © 2009, Oracle. All rights reserved.
Example 3C: Set the Query View Mode
• Use the BC SetViewMode() method to specify the query view mode– Use a predefined constant value as a parameter
• The view mode:– Controls the underlying SQL WHERE clause
– Limits records returned based on team and position
– Is only required for the parent BC for a BO— Parent BC example: the Account BC of the Account BO
• Example: Set the view mode for business component oBC to return all records with a valid owner
// Set the view mode for business component oBC
oBC.SetViewMode(AllView);
AllView is a pre-defined constant
Example 3C: Set the Query View Mode
Permissible values for the view mode include:• SalesRepView: Applies single position or sales team access control• ManagerView: Displays records that the user and the user's direct reports have access to • AllView: Displays all records for which there is a valid owner
These modes are analogous to the visibility filter values available in the Siebel client. For example, My Accounts versus My Team’s Accounts vs. All Accounts.See the Siebel Object Interfaces documentation for additional values and detail.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 15
Copyright © 2009, Oracle. All rights reserved.
Example 3D: Activate Fields for the Query
• Activate fields for use in the query with the BC ActivateField() method– Requires a BC field name as an argument
• Activating fields:– Constructs a SQL SELECT list including those fields
– Makes their values available in the query result set
• Example: Activate the Name and Sales Rep fields for the oBC business component variable
// Activate query fields
with(oBC)
{
ActivateField("Name");
ActivateField("Sales Rep");
}
Example 3D: Activate Fields for the QueryActive FieldsA BC field is active without explicit activation if any of the following conditions are true:
• It is a System field• Its LinkSpec property is set to TRUE• Its Force Active property is set to TRUE• It is visible in an applet in the active view• It is used in a calculated field on the active applet• It is used in a query’s search specification
with BlockThe code segment above shows the with control structure. with() specifies an object instance that all methods contained in the subsequent block are applied to.
Activating Multiple FieldsThe business component method ActivateMultipleFields() can be used to activate multiple BC fields in a single method call. This method takes a single property set as an argument. Because of the overhead of building a property set, this method may not be more efficient than multiple calls to ActivateField().
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 16
Copyright © 2009, Oracle. All rights reserved.
Example 3E: Set the Query Search Specification
• Set the query search specification by:– Calling the BC method ClearToQuery(), which clears the
search specification
– Calling the BC method SetSearchSpec() for each field involved in the query
— Arguments to this method are a field name and an expression in Siebel Query Language
• Example: Set the search specification to query for oBC records with BC field Revenue greater than 999,999:
// Clear search spec and set a new one
with(oBC)
{
ClearToQuery();
SetSearchSpec("Revenue", ">999999");
}
Example 3E: Set the Query Search Specification
Sort Specifications
You can also set a specification for sorting records that are returned by the query using the BC method SetSortSpec(). See the Siebel Object Interfaces documentation for detail and examples.
Siebel Query Language Reference
The Siebel Query Language is discussed in detail in the appendices in Bookshelf’s Siebel Personalization Administration Guide.
Search Specification Fields and Field Activation
You do not need to explicitly activate any fields used in search specifications.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 17
Copyright © 2009, Oracle. All rights reserved.
Example 3F: Execute the Query
• Execute a query by calling the BC ExecuteQuery() method– Takes a single argument, CursorMode
• CursorMode can take one of two constant, pre-defined values:– ForwardOnly: allows uni-directional navigation through the
query result set using NextRecord()— Fastest cursor mode: use whenever possible
– ForwardBackward: allows bi-directional navigation through the query result set using NextRecord() and PreviousRecord()
• Example: Execute a query with ForwardOnly cursor mode
ForwardOnly is a predefined constant
// Execute the query
oBC.ExecuteQuery(ForwardOnly);
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 18
Copyright © 2009, Oracle. All rights reserved.
Example 3G: Use the Query Result Set
• Several BC methods can be used to work with query result sets:– FirstRecord(): sets the cursor to the first record in a result
set, or returns FALSE if the result set is empty
– LastRecord(): sets the cursor to the last record in a result set, or returns FALSE if the result set is empty
– NextRecord(): sets the cursor to the next record, or returns FALSE if at the end of the result set
– PreviousRecord(): only available if CursorMode is ForwardBackward; sets the cursor to the previous record, or returns FALSE if at the first record in the result set
– CountRecords(): returns the number of records returned by the last call to ExecuteQuery()
Example 3G: Use the Query Result Set
Best Practice
Be sure to check the return value of FirstRecord() before attempting to access this record. If the return value is FALSE, then you will not be able to access any returned records, as the result set is empty.
Accessing the Current BC Instance
Once you have positioned the cursor in a query result set, you can call the BC methods GetFieldValue() or GetMultipleFieldValues() to access the current BC.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 19
Copyright © 2009, Oracle. All rights reserved.
Example 3G: eScript Code
• Example: Move to the first record in a result set, and after checking that the result set is not empty, print this record’s Name and Sales Rep to the string variable oString
// Move to first record, verify that the result set is not empty,// and then create a string showing Name and Sales Rep valuesvar oString : chars;with (oBC){
if (FirstRecord()){
Clib.sprintf(oString, "Name is %s and Sales Rep is %s \n", GetFieldValue("Name"), GetFieldValue("Sales Rep"));
}}
Example 3G: eScript Code
The call to Clib.sprintf() allows printing a formatted character string to a characters variable. Clib is an eScript object containing methods similar to those found in the ANSI C library. Clib is available in eScript without any special declarations.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 20
Copyright © 2009, Oracle. All rights reserved.
3H. Destroy Object Instances
• When your script is complete, delete object instances created earlier– Set the object reference to null
– Memory allocated for the object instance is freed
– Delete child objects before parents
• Example: Free the oBC BC instance then the oBO BO instance
Delete the child object (oBC) before the parent
(oBO)
// Clean up allocated objects
oBC = null;
oBO = null;
3H. Destroy Object Instances
Object types that require explicit deletion of object instances are:• Application• BusComp• BusObject• CfgItem• CTIData• CTIService• PropertySet• Service• WebApplet
For details on these types, see Bookshelf’s Siebel Object Interfaces Reference.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 21
Copyright © 2009, Oracle. All rights reserved.
Example 3: Code Example
• The complete code for the query example:
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 22
Copyright © 2009, Oracle. All rights reserved.
Lesson Highlights
• The Siebel Object Interfaces provides APIs for scripting object events and methods– Also includes COM and Java APIs for integrating with
external applications
• The exposed event handlers allow you to script a pre-event handler, a post-event handler, or both– Depends on the object type and event
• Object methods allow you to manipulate object instances programmatically
• Before executing a query in a script:– Set the query view mode
– Activate BC fields
– Set the query search specification
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 5 - 23
Copyright © 2009, Oracle. All rights reserved.
Practice 5 Overview: Using the Siebel Object Interfaces
This practice covers the following topics:
• Manipulate property sets in a script
• Script a query
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Copyright © 2009, Oracle. All rights reserved.
Accessing Object Instances in Siebel Scripts
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 2
Copyright © 2009, Oracle. All rights reserved.
Objectives
After completing this lesson, you should be able to:
• Summarize the differences between user interface (UI) context and non-UI context object instances
• Describe how an Application Object Manager (AOM) creates and manages object instances and how to access these instances in scripts
• Describe how and when to create and access object instances programmatically
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 3
Copyright © 2009, Oracle. All rights reserved.
Uses of Server Scripts
• Server scripts often perform data validation and manipulation:– Interact with the database by query, insert, update, and
delete operations— Identify all Service Requests (SR) older than 7 days and add an
Activity to review the SR
– Access the data a user is currently working with
– Access data beyond the current record or business component
— Do not allow closure of service request if "In Progress" activities exist for the service request
— When a contact’s work number changes, create an outbound call (activity) to verify the new number within 5 days
• To perform these operations, scripts need to work with Siebel object instances
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 4
Copyright © 2009, Oracle. All rights reserved.
Siebel Object Instances
• An object instance is the run-time, in-memory creation of an object definition– Instances are created during normal Siebel application
operation by an Application Object Manager (AOM)
• Example of object instances:– A user is accessing the SIS Account List Applet in the SIS
Account List viewAccount
Business Object
AccountBusiness
Component
Object instances are created to support user operations in the
Account List View
Siebel Object Instances
Diagram
The picture shows the Account List View and the business layer objects that the AOM creates for this view: the Account business object and the Account business component.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 5
Copyright © 2009, Oracle. All rights reserved.
Object Instances and Scripts
• The object instances used in scripts are created in two different ways, or "contexts":– The user interface (UI) context
— Object instances are created and deleted by the AOM in response to user activity
– A non-UI context— Object instances are created and deleted programmatically
AOM
AccountBusiness Object
AccountBusiness
Component
UI Context
AccountBusiness Object
AccountBusiness
Component
Non-UI Context
Script
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 6
Copyright © 2009, Oracle. All rights reserved.
UI Context and Scripts
• Scripts can use objects created in the UI context
• Use the UI context:– To access data the user is currently working with
— Example: trap data values entered by a user before committing them to the database
– To make processing visible to a user— Examples:
— Advance the record pointer in a list applet after processing a record
— Add an activity record and select it in the UI
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 7
Copyright © 2009, Oracle. All rights reserved.
UI Context: Example of Object Instantiation
• This example illustrates how the Object Manager functionality within the AOM creates and destroys object instances as the result of user actions
• The user starts in the Account List View– The Object Manager instantiates the Account business
object (BO) and Account business component (BC)
AccountBusiness Object
AccountBusiness
Component
Account BO is associated with the Account List View
Account BC is associated with both applets
UI Context: Example of Object Instantiation
UI layer objects, such as applets and views are also instantiated by the object manager and are used to render the UI.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 8
Copyright © 2009, Oracle. All rights reserved.
UI Context: Example of Object Instantiation
• The user navigates to the Account Detail - Contacts View– The Account Contact List Applet displays data from the
Contact BC
– The Object Manager instantiates the Contact BC within the Account BO
AccountBusiness Object
AccountBusiness
Component
ContactBusiness
Component
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 9
Copyright © 2009, Oracle. All rights reserved.
UI Context: Example of Object Instantiation
• The user clicks the Activities view tab– The AOM renders the Account Detail - Activities View
– The Object Manager instantiates the Action BC within the Account BO
— The Contact BC instance in the Account BO is not deleted
AccountBusiness Object
AccountBusiness
Component
ContactBusiness
Component
ActionBusiness
Component
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 10
Copyright © 2009, Oracle. All rights reserved.
UI Context: Example of Object Instantiation
• Finally, the user uses the Site Map to navigate to the Activity List View– The AOM renders the new view
– The Object Manager:— Deletes the Account BO and its BC instances
— Instantiates the Action BO and Action BCAccount
Business Object
AccountBusiness
Component
ContactBusiness
Component
ActionBusiness
Component
ActionBusiness Object
ActionBusiness
Component
Deleted
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 11
Copyright © 2009, Oracle. All rights reserved.
UI Context: Object Methods to Use
• Use UI context object instances in server scripts by calling the methods:– Application method ActiveBusObject()
— Returns the currently active BO instance
– Business Object method GetBusComp()— Returns a BC instance for a BO
• Example code: gets the Action BC instance for the current BO
// Get UI context business object and Action child business component
var activeBO : BusObject = TheApplication().ActiveBusObject();
var oBC : BusComp = activeBO.GetBusComp("Action");
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 12
Copyright © 2009, Oracle. All rights reserved.
UI Context: Available BCs
• GetBusComp() can only return a BC instance if the requested BC is a child BC or the parent BC of the current BO – There must be a link definition in the current BO for the
desired child BC
Action/Opportunity Link
BCs available for the Action BO
UI Context: Available BCs
The graphic shows Siebel Tools with the business object Action selected. Below it are the associated Business Object Components which are child object definitions of the Business Object definition.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 13
Copyright © 2009, Oracle. All rights reserved.
UI Context: Available Data Records for a BC
• The data records available for a BC are determined by:– The BC view mode
– BC and Applet search specifications
– Links
– Applet personalization rules
• Can use the BC methods GetSearchSpec() and GetViewMode() to retrieve the current settings for a BC
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 14
Copyright © 2009, Oracle. All rights reserved.
UI Context: Scripting Considerations
• If the user’s session is displaying data for a BC, then calling the NextRecord() method for the BC will highlight the next record in the applet– Moving through the result set will cause the current record to
change
UI Context: Scripting Considerations
The screenshot shows the My Accounts list applet with one record selected and then another shot showing the next record in the list selected.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 15
Copyright © 2009, Oracle. All rights reserved.
Non-UI Context
• Create object instances programmatically– Instances:
— Are empty until populated programmatically
— Allow access to records that have been committed to the database
— Are not associated with UI instances, such as applets or views
• Use if script functionality should not be associated with a user session– Methods calls are not visible to the user
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 16
Copyright © 2009, Oracle. All rights reserved.
Non-UI Context: Using Object Instances
• The steps for using object instances in a non-UI context are:– Create empty object instances
– Query to populate the object instances
– Use methods to access query results
– Delete object instances
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 17
Copyright © 2009, Oracle. All rights reserved.
Non-UI Context: Create Empty Object Instances
• Use creator methods to instantiate new objects
• For non-hierarchical or parent object types, use an Application method– Examples:
— A property set is not part of a hierarchy of object types— Create a property set using the Application method
NewPropertySet()
— A business object is a parent object type— Create a BO using the Application method GetBusObject()
• For child object types, use a creator method for the parent object– Example:
— A BC is a child object of a BO— Create a BC using the Business Object method GetBusComp()
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 18
Copyright © 2009, Oracle. All rights reserved.
// Create business object and business component objectsvar oBO : BusObject = TheApplication().GetBusObject("Account");var oBO : BusComp = oBO.GetBusComp("Account");var oString : chars;
with(oBC){
SetViewMode(AllView); // set up queryActivateField("Name"); // activate fieldsActivateField("Sales Rep");ClearToQuery();SetSearchSpec("Revenue", ">999999"); // Revenue >= $1M
ExecuteQuery(ForwardOnly); // execute query
// print first record field values to a stringif (FirstRecord()){
Clib.sprintf(oString, "Name is %s and Sales Rep is %s \n", GetFieldValue("Name"), GetFieldValue("Sales Rep"));
}// Work with other result set records. . .
oBC = null; // delete object instancesoBO = null;
}
Non-UI Context:Query to Populate the Object Instances
• Example: Query example from a previous lesson
Execute a query
on the Account BC
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 19
Copyright © 2009, Oracle. All rights reserved.
Non-UI Context: Use Methods to Access Query Results
• Navigate between records in a result set using the BC methods:– FirstRecord()
– LastRecord()
– NextRecord()
– PreviousRecord()
• Access BC fields using the BC methods:– GetFieldValue()
– SetFieldValue()
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 20
Copyright © 2009, Oracle. All rights reserved.
Non-UI Context: Delete Object Instances
• To free the memory used by object instances, delete them when done using them– Set the object reference to null
– Always delete child objects before deleting parents
• Example: delete oBC and oBO
BC and BO object instances are deleted
// Delete object instances
oBC = null;
oBO = null;
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 21
Copyright © 2009, Oracle. All rights reserved.
Lesson Highlights
• Server scripts typically need to work with Siebel object instances
• The two contexts for accessing object instances are:– UI Context:
— The AOM creates, manages, and deletes object instances associated with a user session
— Use ActiveBusObject() to access the current BO
– Non-UI Context:— Object instances are created, managed, and deleted
programmatically
— Object instances are not associated with UI objects
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 6 - 22
Copyright © 2009, Oracle. All rights reserved.
Practice 6 Overview: Exploring Object Instance Contexts
This practice covers the following topics:
• Explore a script that uses object instances from the UI context
• Explore a script that uses object instances in a non-UI context
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Copyright © 2009, Oracle. All rights reserved.
Writing Good Scripts
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 2
Copyright © 2009, Oracle. All rights reserved.
Objectives
After completing this lesson, you should be able to:
• Follow best practices for writing scripts
• Use eScript techniques for script libraries, memory management, and error handling
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 3
Copyright © 2009, Oracle. All rights reserved.
Using Software Best Practices in Scripting
• Scripting is a form of software development and should use established software best practices and techniques
• Using professional software practices will result in scripts that:– Are correct
— Using defensive programming and testing techniques can ensure that your scripts meet requirements
– Can be maintained easily— Maintenance is frequently the largest component of total
software cost, even for relatively small, "simple" projects
– Perform well— Good software design can provide better performance
Using Software Best Practices in Scripting
Scripting Performance
Scripting performance measurement and specific performance recommendations for Siebel scripting are the topics of an upcoming lesson.
eScript and Siebel VB
This lesson focuses on both general and language-specific coding techniques. Whenever a specific API is discussed, such as the tracing API, the eScript interface is shown. However, all of the eScript methods discussed have Siebel VB counterparts. Refer to Bookshelf’s Siebel VB Language Reference for details.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 4
Copyright © 2009, Oracle. All rights reserved.
Scripting Techniques and Best Practices
• Techniques and best practices that lead to better, more robust scripts include using:– Encapsulation
– Comments and general software methodology
– Naming conventions
– Script Libraries
– Exception Handlers
– Trace during development
– Translatable messages
– Standard libraries
– Complex data types
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 5
Copyright © 2009, Oracle. All rights reserved.
Encapsulation
• Encapsulation in a piece of software refers to separating the interface presented by the code from its implementation– The interface for a program or script includes its input and
output arguments, as well as its functionality
• Different Siebel object types offer differing levels of encapsulation– Scripting some Siebel object types, such as Applet, imposes
less flexible implementations
Business Service
Application
Business Component
Applet
high (better)high (better)
Level of encapsulationLevel of encapsulation
lowlow
Encapsulation
Using Business Services
Business services are reusable object definitions which can carry out custom coded functionality, and can be called from any place inside the Siebel application and from other applications. Business services are highly reusable, and it is highly recommended to use them to implement custom functionality whenever possible. Scripting custom business services and invoking them from Siebel and other applications are topics of upcoming lessons.
Diagram
The picture indicates the level of encapsulation for different scripted object types. In general, Applet scripts offer the least amount of encapsulation, while business services offer the most.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 6
Copyright © 2009, Oracle. All rights reserved.
Comments and General Software Methodology
• Comment your code:– Others might want to read it and may have to support it
– In complex scripts, create a header section to hold author and changes history
• Keep a clear structure:– Adhere to project guidelines for code layout (such as naming
conventions, placement of brackets or comments)
• For complex or intensive scripting, apply IT industry best practices:– Software configuration management (SCM)
— ST supports integration with SCM tools like IBM‘s Clearcase
– Use established quality and testing practices— Example: formal code reviews typically identify and eliminate a
large number of bugs before testing
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 7
Copyright © 2009, Oracle. All rights reserved.
Adding Comments to Scripts
• eScript and JavaScript support C++/Java syntax for commenting code:
function Comment_Styles(){
// eScript and JavaScript support two types of comments:
// Using two slashes, like this comment, marks the rest of a line as a// comment. Comment blocks require double slashes for each line.
/* This style of comment uses "slash asterisk" and "asterisk slash" asdelimiters. All text between these delimiters is a comment. Usingconsistent tabbing and alignment makes these blocks more readable.
*/
// Good places to comment include:// * Overall code headers, where you document authorship and changes// * Function headers// * Any section of code that is difficult or obscure
// Commenting can also be used to deactivate test or debugging code}
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 8
Copyright © 2009, Oracle. All rights reserved.
Naming Conventions
• Using naming conventions and descriptive variable and function names:– Produces better documented code
– Enhances code maintainability
– Examples:— A variable named "StrLength" is easier to understand than "len"
or "L"
— Using mixed case variable or function names can make code more readable: ReverseString() versus REVERSESTRING()
• Companies may mandate specific conventions for code
Naming Conventions
Prefix Conventions
Another useful type of naming convention is to use short prefixes to identify variable types or usage. Siebel example scripts use the convention that object variables are prefaced with "o", or in cases where there is no ambiguity, using prefixes "i" and "o" to denote input and output variables.Examples:var oBC : BusComp; // oBC is a business component instance
var iPS, oPS : PropertySet; // iPS and oPS are input and output property setsO
racl
e U
nive
rsity
and
(Ora
cle
Cor
pora
tion)
use
onl
y.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 9
Copyright © 2009, Oracle. All rights reserved.
Script Libraries
• Script libraries allow developers to create reusable business service functions which are easy to call– No need to create property sets and call InvokeMethod
• Using script libraries produces:– Simpler, easier-to-use (and reuse) code
– More readable scripts
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 10
Copyright © 2009, Oracle. All rights reserved.
Script Library Example
• Add a wrapper function to the SCR Calculator business service to allow direct invocation of its Add method– Add this function to the general declarations for the script
SCR_EasyAdd() is a wrapper function to invoke the Add
method
function SCR_EasyAdd(arg1 : Number, arg2 : Number) : Number{
// This function is part of the SCR Calculator business service script// and allows the service's Add method to be called directly, instead // of through a call to InvokeMethod()// Example call: result = SCR_EasyAdd(2.0, 3.5);
var iPS : PropertySet = TheApplication().NewPropertySet();var oPS : PropertySet = TheApplication().NewPropertySet();var sum : Number;
// Initialize input properties to this function's input argumentsiPS.SetProperty("Arg1", arg1);iPS.SetProperty("Arg2", arg2);
// Invoke SCR Calculator's Add methodthis.InvokeMethod("Add", iPS, oPS);
// Get result from the output property set and convert from// a string to Numbersum = ToNumber(oPS.GetProperty("Result"));
return (sum);}
Script Library Example
This code sample shows how to take a business service method and make it directly callable in other scripts. Another script can now invoke the Add business service method by calling:sum = SCR_EasyAdd (arg1, arg2);It might seem strange to still have the method definition: why not just implement Add in the Easy Add function? However, by defining a business service method, and providing a wrapper for it, you get a method that can be used throughout a Siebel application, not just in scripts, and can also be called with simplified syntax in a script.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 11
Copyright © 2009, Oracle. All rights reserved.
Script Library Example
• A different script can invoke the Add method by:– Initializing a business service object for SCR Calculator
– Calling the wrapper function
function ScriptLibraryTest(){
// This function (not part of SCR Calculator) shows how to call// a business service method that has a script library wrapper
// Instantiate the business service objectvar oSvc : Service = TheApplication().GetService("SCR Calculator");
// Invoke the Add method using the wrapper functionvar sum : Number = SCR_EasyAdd(2.0, 3.5);
// Tool Tips are available for the wrapper functionvar sum2 : Number = SCR_EasyAdd(
}
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 12
Copyright © 2009, Oracle. All rights reserved.
Exception Handlers: Overview
• When scripting in eScript, use try, catch(), and throw() to handle exceptions– Similar to Java and C++ exception handling APIs
– Allows "centralization" of error handling
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 13
Copyright © 2009, Oracle. All rights reserved.
Handling Exceptions: try and catch()
• To handle exceptions in a section of code:– Put the code in a try block
– Follow the try block with a call to catch() that handles errors— The catch clause may simply report the error
• Example:
try block anticipates errors in functions
SCRAdd() and SCRSubtract()
catch clause sets ErrorMessage property in the
Outputs property set
try{
// call user-provided functions for each methodswitch (MethodName){
case "Add":SCRAdd(Inputs, Outputs);break;
case "Subtract":SCRSubtract(Inputs, Outputs);break;
default:break;
}}catch (e){ Outputs.SetProperty("ErrorMessage", e.toString()); }
Handling Exceptions: try and catch()
A try block can also have a finally() clause, which follows the catch() clause. Use finally() to perform any cleanup, such as freeing memory, before ending execution. See Bookshelf’s Siebel eScript Language Reference for details on how to use finally() correctly.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 14
Copyright © 2009, Oracle. All rights reserved.
Handling Exceptions: throw()
• When an error occurs in a script within a try block, call throw() to handle the error– Execution continues in catch clause for containing try block
– The try block may be higher in the function call hierarchy than the call to throw()
– Example:
function SCRAdd (Inputs, Outputs) // Add two floating point inputs{
// Get input arguments and initialize output argvar arg1 : float = Inputs.GetProperty("Arg1");var arg2 : float = Inputs.GetProperty("Arg2");var sum : float = 0.0;
// if either argument is not a number (NaN), then throw an exceptionif ((arg1 == NaN) || (arg2 == NaN))
throw("Invalid argument type in SCRAdd");
sum = arg1 + arg2;Outputs.SetProperty("Result", sum);
}
SCRAdd() called in previous example
If invalid arguments,
throw an exception
Handling Exceptions: throw()
Example: catching the exception
In this example, the exception is being handled with catch() in a calling function. The try, catch(), throw() exception handling mechanism decouples the reporting of exceptions (with throw()) from the exception response (with catch()). This decoupling allows you to handle errors at the proper level, and eliminates redundant error handling code. In the example shown in this and the previous slide, all exceptions in SCRAdd() and SCRSubtract() are handled in a single catch() block, and there is no need to create separate error handling code in both functions.Alternatives to throw()
You can also use the RaiseError() or RaiseErrorText() methods which allow for replaceable parameters and multi-lingual message handling.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 15
Copyright © 2009, Oracle. All rights reserved.
Trace During Development
• The Siebel Object Interfaces has three Application methods that support tracing memory allocation or SQL statements:– TraceOn() starts tracing and takes arguments:
— Trace file name: a file to log trace information to— Use double-backslashes or forward slashes for file paths:
"D:\\MyDir\\tracefile.log" and "D:/MyDir/tracefile.log" both work
— Trace type: allocation or SQL
— Selection: If trace type is "allocation", this specifies the types of objects whose allocation will be traced
– Trace(TraceMessage) appends a comment to the trace file
– TraceOff() stops tracing
• Trace calls should be removed from production scripts
Trace During Development
Tracing incurs a performance penalty and should not be used in a production environment.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 16
Copyright © 2009, Oracle. All rights reserved.
// Trace SQL statementsTheApplication().TraceOn("D:/TEMP/trace.txt", "SQL", "");TheApplication().Trace("Starting Trace");
// Prepare and execute a query...oBC.ExecuteQuery();...
// Stop tracingTheApplication().TraceOff();
Tracing Example
• The following code excerpt shows how to use tracing– Trace file is D:\TEMP\trace.txt
– Trace type is SQL: trace output will show SQL statements
Turn on tracing
Turn off tracing
Append message to the trace file
Tracing Example
The selection argument in TraceOn() is set to "" in this example, as it should when Trace type is "SQL".
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 17
Copyright © 2009, Oracle. All rights reserved.
Tracing Output
• The previous SQL tracing example results in the following trace output:
Comment from call to Trace()
SQL statement information
Tracing Output
The picture shows the log file for SQL tracing. The script query resulted in a SQL select statement being issued to the Siebel database.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 18
Copyright © 2009, Oracle. All rights reserved.
Other Scripting Diagnostics
• Other techniques can be used to monitor script execution, including using:– Server component logging to monitor events, such as:
— Applet methods and UI navigation
— Business Component events, including creation and deletion
— Business Service-related events
— Data operations, including SQL tracing
– The Siebel Script Performance Profiler
– Siebel Application Response Measurement (SARM)Covered in a later lesson
Other Scripting Diagnostics
Server component monitoring, including AOM monitoring and logging, is covered in Bookshelf’sSiebel System Monitoring and Diagnostics Guide, "Configuring Siebel Server and Component Logging".
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 19
Copyright © 2009, Oracle. All rights reserved.
Translatable Messages
• Should avoid displaying static text to users in scripts– Does not easily support multilingual implementations
– Does not allow message reuse
• Use TheApplication().LookupMessage() to get message text from a library of messages in the Siebel Repository
• A message library is implemented using the Message Category object type– Supports Symbolic Strings, parameter substitution, and
localization
Parameterized message Symbolic String
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 20
Copyright © 2009, Oracle. All rights reserved.
if (isRecord) // Create the message{
message = TheApplication().LookupMessage("Script Messages", "AboutCreatorInfo",oBC.GetFieldValue("Full Name"),oBC.GetFieldValue("Position"),oBC.GetFieldValue("Phone #"),oBC.GetFieldValue("EMail Addr"),oBC.GetFormattedFieldValue("Fax #"));
Outputs.SetProperty("err_flag", "N");Outputs.SetProperty("message", message);
}else // something wrong{
message = TheApplication().LookupMessage("Script Messages", "NoRecordFound",oBC.Name());
Outputs.SetProperty("err_flag", "Y");Outputs.SetProperty("err_message", message);Outputs.SetProperty("err_number", 10);Outputs.SetProperty("message", message);
}
Translatable Messages Example
• This script fragment looks up two messages and uses message parameters:
Message library name
Message nameMessage
parameters
Message name
Message library name
Message parameter
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 21
Copyright © 2009, Oracle. All rights reserved.
Translatable Messages: Reporting Errors
• To use messages to report an error in a script, call the Application RaiseError() method– Presents an error message in the browser
– Uses the predefined Message Category "User Defined Errors"
– Calling Syntax: TheApplication().RaiseError(<MessageKey>, <parameter 1>, …, <parameter N>)
• This method raises an exception:– Code following the method call will not be executed
– If used in a try block, the catch block will be executed
– Recommendation: To display an error message, use RaiseError() in the catch block
— Simply call throw() in the try block
Reporting Errors
To raise a static text message to the browser, use the Application method RaiseErrorText(). This method is not recommended for displaying text to users, but may be useful for script debugging and testing.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 22
Copyright © 2009, Oracle. All rights reserved.
Standard Libraries
• eScript includes two useful objects that allow access to standard function libraries– Clib allows access to functions in the ANSI C library
— Examples: Clib.fopen(), Clib.isupper()
– SElib allows access to external libraries of functions— SElib also includes low-level methods to determine and access
memory addresses— Use these methods with great care to avoid hard-to-find errors
— Example: SElib.dynamicLink() allows you to call a procedure in a DLL (Windows) or in a shared library (UNIX)
Standard Libraries
SElib.dynamicLink()
Refer to Bookshelf’s Siebel eScript Language Reference for information on how input and output parameters for calls to DLLs or shared libraries are handled.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 23
Copyright © 2009, Oracle. All rights reserved.
Complex Data Types
• eScript also has libraries for using complex data types, such as binary large objects (BLOBs), Buffers, Dates, Strings, and regular expressions (RegExps)– eScript provides methods for these and other data types
– See the Siebel eScript Language Reference for details
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 24
Copyright © 2009, Oracle. All rights reserved.
Lesson Highlights
• Scripting is a form of software development and should use established software best practices and techniques
• Techniques to write better scripts include:– Encapsulation
– Comments and general software methodology
– Naming conventions
– Script Libraries
– Exception Handlers
– Trace
– Translatable messages
– Standard libraries
– Complex data types
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 7 - 25
Copyright © 2009, Oracle. All rights reserved.
Practice 7 Overview
This practice covers the following topics:
• Trace code execution
• Create a Message Category and Messages and use them in a script
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Copyright © 2009, Oracle. All rights reserved.
Scripting Custom Business Services
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 2
Copyright © 2009, Oracle. All rights reserved.
Objectives
After completing this lesson, you should be able to:
• Correctly implement business service event handlers
• Create a business service and child object definitions
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 3
Copyright © 2009, Oracle. All rights reserved.
A Business Service
• Is a unit of functionality that is reusable and globally accessible– Analogous to a software library
• Allows business logic to be executed repeatedly in multiple different contexts– Business logic is not restricted to a specific object (business
component, applet, and so forth)
• Consists of one or more operations called methods– Each method has a set of input and output arguments, each
with a specified type
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 4
Copyright © 2009, Oracle. All rights reserved.
Prebuilt Business Services
• Siebel repository contains many prebuilt business services to support processing in areas such as:– Enterprise application integration (EAI)
— EAI Siebel Adapter
— EAI HTTP Transport
– XML document processing— XML Hierarchy Converter
— XML Converter
– Communications— Outbound Communications Manager
— Inbound E-mail Manager
• Be sure to check for prebuilt alternatives before implementing a custom business service
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 5
Copyright © 2009, Oracle. All rights reserved.
Roadmap: Implementing a Custom Business Service
• An important use of scripting is to implement a custom business service
• Elements of creating a custom business service that are discussed in this lesson are:– How Siebel applications interact with a custom business
service— How parameters are passed to and from a business service
method
— Event handling for business service
– How to "publish" information about a custom business service
— Creating object definitions in Siebel Tools
• Methods of invoking a custom business service are discussed in the next lesson
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 6
Copyright © 2009, Oracle. All rights reserved.
How Siebel Applications Interact with a Business Service
• To implement a custom business service you must understand:– Business service event handler input and output parameters
– Business service event handlers
– Where to enter business service code
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 7
Copyright © 2009, Oracle. All rights reserved.
Business Service MethodInput and Output Arguments
• Whenever a business service method is invoked, a sequence of event handlers runs
• Input arguments to the method are passed into the relevant event handlers in a property set– Recall: a property set is a collection of name/value pairs
• Output arguments can be returned from a business service method in a second, output property set
• Example business service event handler:
function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
An event handler function prototype
Input argument property set
Output argument property set
Business Service Method Input and Output Arguments
Invoking a business service method in a script was covered in a previous lesson
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 8
Copyright © 2009, Oracle. All rights reserved.
Business Service Event Handlers
• When invoking a business service method, there are three Business Service event handlers that may run:– Service_PreInvokeMethod
– Siebel-Installed handler
– Service_InvokeMethod
Service_PreInvokeMethod
Service_InvokeMethod
Siebel-Installed Handler
= user-scripted
= Siebel-provided
• One other handler, Service_PreCanInvokeMethod, is used to determine who can invoke a method
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 9
Copyright © 2009, Oracle. All rights reserved.
Service_PreInvokeMethod
• The PreInvokeMethod event is called before Siebel-provided code in the business service is invoked– For a custom business service, this handler is where all the
method execution occurs (or is dispatched from)
• This handler takes arguments:– Business service method name
– Input property set
– Output property set
• For custom methods, return CancelOperation– Returning ContinueOperation will execute the Siebel-
installed handler, which will raise an error
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 10
Copyright © 2009, Oracle. All rights reserved.
Service_PreInvokeMethod Example
• Call a user-provided function for each method
Call method-specific user
function
Catch thrown exceptions here
function Service_PreInvokeMethod (MethodName, Inputs, Outputs){
try{
// call user-provided functions for each methodswitch (MethodName){
case "Add":SCRAdd(Inputs, Outputs);break;
case "Subtract":SCRSubtract(Inputs, Outputs);break;
case "Multiply":SCRMultiply(Inputs, Outputs);break;
case "Divide":SCRDivide(Inputs, Outputs);break;
default:break;
}}catch (e){Outputs.SetProperty("ErrorMessage", e.toString()); }return (CancelOperation);
}
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 11
Copyright © 2009, Oracle. All rights reserved.
The Siebel-Installed Handler
• This handler produces different results for built-in and custom business services:– For built-in business services, this handler will execute the
C++ code for the business service method
– For custom business services, this handler will not find code for the method and raise an error
• For a custom business service, you must return CancelOperation in one of the two preceding handlers to avoid execution of the Siebel-installed handler
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 12
Copyright © 2009, Oracle. All rights reserved.
Event Handler Execution Sequence: Built-In versus Custom Business Services
• The sequence of event handler execution for built-in and custom business services:
Service_PreInvokeMethod
Service_InvokeMethod
Siebel-Installed Handler
Service_PreInvokeMethod
Service_InvokeMethod
Siebel-Installed Handler
Not executed
CancelOperation
Prebuilt Business Service Custom Business Service
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 13
Copyright © 2009, Oracle. All rights reserved.
Service_InvokeMethod
• This handler is rarely scripted– Can only be used for built-in business services
• Can be used for post-operation events– Example: posting a notice to a log when business service
method execution completes successfully.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 14
Copyright © 2009, Oracle. All rights reserved.
Service_PreCanInvokeMethod Event Handler
• Is called by the AOM to determine if a Command can invoke a business service method– Script this handler if you want to restrict access to a business
service method
• Is passed two arguments:– MethodName: the method being called
– &CanInvoke: a reference to a parameter that you set to:— True, if the user is allowed to invoke the method
— False, if the user is not allowed to invoke the method
• Return:– CancelOperation to proceed normally
– ContinueOperation will cause an exception for a custom method
Service_PreCanInvokeMethod Event Handler
Command Object
Command objects are covered in the next lesson. A Command is associated with an applet or application menu item, or a toolbar button.&CanInvokeThe ampersand before the variable CanInvoke in the event handler prototype indicates that this variable is passed by reference rather than by value (the default). This eScript syntax is similar to C++’s. CanInvoke is a reference to a variable external to the handler, rather than a local copy, so setting the variable’s value can be used to communicate with the Siebel event handling framework.CancelOperation and ContinueOperation
These return values are global constants.Return Value
The return value of this routine is unintuitive. However, for a custom method, returning ContinueOperation causes execution to continue with Siebel code that will not recognize the method. Execution of this Siebel code will cause an "Unknown method error".
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 15
Copyright © 2009, Oracle. All rights reserved.
Where to Enter Business Service Code
• For business services it can be unwieldy to enter all business service code in the event handler function
• Use a switch() block in the PreInvokeMethod handler to dispatch method execution to a custom function
Execute custom function based on
MethodName
PreInvokeMethod handlerAdd custom functions here
Where to Enter Business Service Code
Client-Entered Business Services
A custom business service can also be created by entering code directly into the Siebel client. Such business services are entered in the Administration - Business Service > Details view. This client view provides no debugging and few code editing features, so while this method can be used to prototype small business services, it is not recommended for more complex business services. O
racl
e U
nive
rsity
and
(Ora
cle
Cor
pora
tion)
use
onl
y.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 16
Copyright © 2009, Oracle. All rights reserved.
Creating a Business Service in Siebel Tools
• The steps to implement a business service in Siebel Tools are:1. Create a Business Service object definition
2. Create Business Service Method and Method Arg object definitions (optional)
3. Create Business Service Script objects
4. Compile the Project
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 17
Copyright © 2009, Oracle. All rights reserved.
1. Create a Business Service Object Definition
• In Siebel Tools create a new record of type Business Service
• Specify properties, including:– Business Service name
– Project
– Display Name
– External Use flag: always set to TRUE
– Web Service Enabled: TRUE means the business service is exposable and callable as a Web service
Business service properties
1. Create a Business Service Object Definition
Setting Web Service Enabled to TRUE is required to allow a business service to be called as a Web service, but is not sufficient to enable the service as a Web service. The process of allowing a business service to be accessed as a Web service is covered in a future lesson.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 18
Copyright © 2009, Oracle. All rights reserved.
2. Create Business Service Method and Method Arg Object Definitions
• Create Business Service child object definitions so methods and arguments are available in picklists in Siebel Tools and the Siebel client
• For Business Service Method definitions, specify Name and Display Name
• For Business Service Method Arg definitions, specify:– Argument name
– Data Type: Number, String, Date, and so on
– Type: Input or Output argumentBusiness Service Method definition
for Add
Business Service Method Arg definitions
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 19
Copyright © 2009, Oracle. All rights reserved.
3. Create Business Service Script Objects
• Right-click the Business Service record in the Object List Editor (OBLE) and select Edit Server Script or Edit Browser Script
• Enter or import code into the Siebel script editor
Right-click to show pop-up menu
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 20
Copyright © 2009, Oracle. All rights reserved.
4. Compile the Project
• When script has been tested and saved, compile the project that contains the business service– Use Tools > Compile Projects
• The Business Service and all child object definitions are compiled into the Siebel repository file (.srf)
4. Compile the Project
You can compile individual objects, such as a Business Service, instead of compiling the object’s project. Select the object definition in the Siebel Tools’ Object List Editor, right-click, and select Compile Selected Objects. This will typically be faster than project compilation if the project contains many other objects definitions.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 21
Copyright © 2009, Oracle. All rights reserved.
Lesson Highlights
• Business service event handlers are:– Service_PreCanInvokeMethod
– Service_PreInvokeMethod
– A Siebel-installed handler
– Service_InvokeMethod
• Custom business services implement their functionality in the Service_PreInvokeMethod event handler or in a function called by this handler
• To create a business service in Siebel Tools:– Specify a Business Service object definition and child object
definitions
– Create a script object and enter script
– Compile the project for the business service
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 8 - 22
Copyright © 2009, Oracle. All rights reserved.
Practice 8 Overview: Creating Business Services
This practice covers the following topics:
• Add a method to a custom business service
• Create Business Service and child object definitions
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Copyright © 2009, Oracle. All rights reserved.
Invoking Business Services
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 2
Copyright © 2009, Oracle. All rights reserved.
Objectives
After completing this lesson, you should be able to:
• List ways to invoke a business service method
• Invoke a business service method as part of an event’s action set
• Invoke a business service method using Siebel user interface (UI) objects
• Expose a business service as a Web service
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 3
Copyright © 2009, Oracle. All rights reserved.
Invoking Business Services
• Siebel business service methods can be invoked in a variety of ways in a Siebel application and by external applications:– From a Siebel application:
— Programmatically— Covered in an earlier lesson
— In a workflow or task step
— In a runtime event action set
— In the user interface (UI):— Applet- or application-level menu
— Button
– From an external application:— As a Web service
Invoking Business Services
Programmatic Invocation
Two methods for invoking a business service method were covered in earlier lessons: using the Service method InvokeMethod(), and using a script library, if supported.
Workflow and Task Invocation
Business service steps for Siebel workflow processes and Siebel tasks were discussed in a previous lesson. Details on constructing workflows can be found in Bookshelf’s Siebel Business Process Framework: Workflow Guide, and Siebel tasks are covered in Siebel Business Process Framework: Task UI Guide.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 4
Copyright © 2009, Oracle. All rights reserved.
Siebel Workflow
• A workflow process is an ordered set of steps executed in response to a defined set of conditions
• Siebel Workflow provides:– A set of tools to graphically define workflow processes
– An engine to automate these processes
Workflow processes are
created in Siebel Tools’
Workflow Designer
Siebel Workflow
Siebel Workflow is one of the most commonly-used forms of business automation in Siebel applications. Siebel CRM comes with hundreds of seed workflows that provide the out-of-the-box functionality of modules such as Siebel Marketing, Siebel Customer Order Management, and Siebel Loyalty. Siebel Workflow is a mix of declaratively- and administratively-configured functionality. While workflow processes are configured in Siebel Tools by developers, they are not compiled into the .srf file. In addition, workflow activation and deactivation can be done by application administrators.
Reference
Bookshelf’s Siebel Business Process Framework: Workflow Guide
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 5
Copyright © 2009, Oracle. All rights reserved.
Invoking a Business Service Method in a Workflow or Task
• A workflow process or task can invoke a business service method using a Business Service step– Step information includes the business service name,
method name, and input and output parameters
Business service step
Input arguments
Business service name and method
Invoking a Business Service Method in a Workflow or Task
Workflow Process and Tasks
Siebel Workflow and Siebel Task UI are covered in the Siebel 8.1.x Business Automation course offered by Oracle University. See Oracle University’s website for details.
Tasks
The diagram above shows a workflow process. Siebel tasks are depicted in the Siebel Tools’ Task Designer in a similar manner, and a business service step is configured the same way in the Designer.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 6
Copyright © 2009, Oracle. All rights reserved.
Runtime Events
• Allow a Siebel application to perform one or more actions in response to a specified event– Actions are executed by the Siebel personalization engine
— Siebel Personalization is a framework for runtime application customization
– Each action set is associated with an object type, object name, and event
• Are viewed in the Administration - Runtime Events screen
Runtime Events
Reference
Runtime Events are discussed in the Siebel Personalization Administration Guide.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 7
Copyright © 2009, Oracle. All rights reserved.
Action Set
• Is a set of actions that are executed when an event occurs
• Can include one or more calls to business service methods– To add a business service method to an action set, specify:
— Business Service Name and Method Name
— Context: a string that is passed to the method
Action set
An action
Business service name, method, and context for
this action
Action Set
Action Sets and Events
Notice that an action set is not associated with a single event. Instead, it is defined separately and can be associated with multiple events.
Business Service Context
Business Service Context allows entry of a string. This string is passed to the business service method as part of a property set, along with the other parameters:
• Action Set name: from the Action Sets applet• Action name: from the Actions applet shown above (the middle applet)• Event ID: Row Id of the event that caused the action set to execute• Event name: from the Events list applet• Event type• Object name: the name of the object that is in context when the event occurs• Business component name
If you need to pass multiple input arguments to a method, the Context value can be used. The value you provide is passed in a name/value pair: "Context", "context string". You can embed a collection of name/value pairs in context string, and then unpack them in your script.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 8
Copyright © 2009, Oracle. All rights reserved.
Invoking a Business Service Method with a Runtime Event
• To invoke a business service method using runtime events:– Navigate to Administration - Runtime Events > Action Sets
– Create an action set that invokes the business service method
— Specify business service name, method name, and business service context
– Create an event record for the triggering event
– Specify the action set you just created
– In the Events applet, select Menu > Reload Runtime Events
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 9
Copyright © 2009, Oracle. All rights reserved.
Invoking a Business Service from the Siebel UI
• A business service method can be invoked in the Siebel UI from:– The application menu
– A button on the application toolbar
– An applet menu
– A button on an applet
Invoking a Business Service from the Siebel UI
This section of the lesson provides an overview of how to invoke a business service method from the Siebel UI. For details on the object types discussed and their properties, refer to the Siebel Object Types Reference. Configuring a Siebel application by creating and modifying object definitions in Siebel Tools is the topic of Oracle University’s Siebel 8.1.x Tools course. See Oracle University’s website for course details. O
racl
e U
nive
rsity
and
(Ora
cle
Cor
pora
tion)
use
onl
y.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 10
Copyright © 2009, Oracle. All rights reserved.
Configuring the Siebel UI
• Invoking a business service method from the UI requires that you create and compile object definitions in Siebel Tools– You will need to create several object definitions and set
object definition properties to link them together— The types of object definitions required depends on how the
business service method is invoked
• The business service method and its input arguments are linked to one of three "infrastructure" object types:– Command object
– Applet Named Method
– Business Component Named Method
Configuring the Siebel UI
Object Types
Applet and Business Component Named Methods are User Properties for their respective parent classes. Each provides a way to extend the functionality of their parent object by allowing new object methods. However, an Applet Named Method is used to link a business service method with a specific applet definition, while a Business Component Named Method links a business service method with a specific business component. Command objects are discussed in the slides that precede Practice 9a.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 11
Copyright © 2009, Oracle. All rights reserved.
Steps to Invoke a Business Service Methodfrom the Siebel UI
• The following slides give the top-level steps required to invoke a business service method from:– An application menu item
– The application toolbar
– An applet menu
– A button on an applet
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 12
Copyright © 2009, Oracle. All rights reserved.
Invoking a Business Service Method:From an Application Menu Item
1. Create a Command object• Specify the business service, method, and argument
2. Create a Menu Item definition• Reference the Command object
Create a command
Specify the command in the
Menu Item
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 13
Copyright © 2009, Oracle. All rights reserved.
Invoking a Business Service Method:From the Application Toolbar
1. Create bitmaps for the new toolbar button– Create new object definitions in Bitmap Category :: HTML
Command Icons | Bitmap
– Need separate bitmaps for the enabled and disabled states
– Copy the bitmap files to ...\SWEApp\PUBLIC\<lang>\images to deploy them on the Web server
Disabled and enabled state
bitmaps
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 14
Copyright © 2009, Oracle. All rights reserved.
Invoking a Business Service Method:From the Application Toolbar
2. Create a Command object– Specify business service, method, and input argument
3. Create a new Toolbar Item that references the Command– Toolbar Item is a child of Toolbar
CommandToolbar
Item
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 15
Copyright © 2009, Oracle. All rights reserved.
Invoking a Business Service Method:From an Applet Menu Item
1. Create a Command object
2. Select the Applet definition
3. Select Edit Web Menus
4. Add a new menu item
Specify the command object here
Double-click and enter menu item
properties
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 16
Copyright © 2009, Oracle. All rights reserved.
Invoking a Business Service Method:From a Custom Control
1. Create an Applet Named Method, specifying the business service, method, and an argument
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 17
Copyright © 2009, Oracle. All rights reserved.
Invoking a Business Service Method:From a Custom Control
2. Create a Control for the Applet• Control is a child object of Applet
• Specify the Named Method for the control
AAAButton is configured to invoke the
InvokeSmartScript named method
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 18
Copyright © 2009, Oracle. All rights reserved.
Web Services
• Are software components that provide well-defined units of application functionality– Are typically made available on Web servers
• Are independent of the client’s platform, operating system, and programming language
• Use message-based communication
• Have published descriptions of the interface– Allows clients to import the descriptions that specify the
structure of the invoking and response messages
Web Services
Reference
Using Siebel applications with Web services is the subject of the Siebel CRM Web Services Reference.
Web Services Protocols
Web services are built on standard protocols, including:• XML for representing the messages• Simple Object Access Protocol (SOAP) for formatting the message• Web Services Description Language (WSDL) for describing the service• Universal Description, Discovery, and Integration (UDDI) to serve as a registry or directory of
services
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 19
Copyright © 2009, Oracle. All rights reserved.
Invoking a Business Service Method:As a Web Service
• A business service or workflow process can be published directly as a Web service in Siebel Tools– Right-click the service or process, and select Deploy as a
Web Service
– Runs the Web Service Deployment Wizard
Select the business service, then Deploy as Web Service
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 20
Copyright © 2009, Oracle. All rights reserved.
Web Service Deployment Wizard
• Allows you to specify the exposed Web service names, Web service address, and ports
Select methods
Configure URL
Modify names
Web Service Deployment Wizard
Web Service Deployment
Deployment makes the business service methods available as Web service operations, as you can see in the listing shown. Each Web service operation corresponds to a method. The URL shown is used by the remote application that is accessing the Siebel business service. The checkbox Generate WSDL is used if you wish to create a Web Services Description Language (WSDL) file for use by the remote application.
Method Arguments
To be deployed as a Web service, a business service must have methods that take simple data types, such as strings or numbers, as input and output arguments. Other arguments, such as Property Sets (see next note), must be exposed as Integration Objects
Property Set Arguments
If a business service method takes a property set, which is not a data type known to Web services, as an input argument, then you have to create an integration object equivalent to the property set. This integration object will be used to pass data to the business service method through a Web services data type Hierarchy.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 21
Copyright © 2009, Oracle. All rights reserved.
Lesson Highlights
• A business service method can be invoked in many ways, including:– In a Siebel application:
— Programmatically in a server or browser script
— In a workflow process or task
— In an action set for a runtime event
— In the Siebel UI
– From an external application:— As a Web service
• Object types that support UI invocation of business service method include:– Command
– Applet Named Methods
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9 - 22
Copyright © 2009, Oracle. All rights reserved.
Practice 9 Overview: Invoking Business Services
This practice covers the following topics:
• Expose a business service as a Web service
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Copyright © 2009, Oracle. All rights reserved.
Scripting Project
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9a - 2
Copyright © 2009, Oracle. All rights reserved.
Objectives
In this practice, you will:
• Invoke a business service method from the Siebel UI
• Communicate between a browser script and a server script
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9a - 3
Copyright © 2009, Oracle. All rights reserved.
Project Summary: Calling a Server Business Service from a Browser Script
Requirement: Display information about a record’s creator• Invoked from the application menu
• Must work for records of all types
Challenge: Data display must be handled in the browser and data retrieval must take place on the server
Solution Overview: • A browser-based business service passes information about the
active business component to the server-side business service
• A server script queries for user data and passes it back to the browser script
• The browser script displays the data
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9a - 4
Copyright © 2009, Oracle. All rights reserved.
Project Requirement
• For each record displayed in Siebel Call Center, allow the user to display information about the record creator
• This feature should be invoked by an item in the Help menu
• Information displayed should include the record creator’s:– Name
– Position
– Phone number
– Email address
– Fax Number
Display creator information
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9a - 5
Copyright © 2009, Oracle. All rights reserved.
Solution Overview
• You will implement the requirement using:– A browser business service that passes the active business
component to a server business service and then displays query output
– A server business service that queries for creator information
– A Menu Item and a Command object to invoke the browser business service
– Message objects to communicate and display query data
Browser-basedBusiness Service
Server-basedBusiness Service
Queries for creatorinformation
Initiates query and displays information
Menu Item Command
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9a - 6
Copyright © 2009, Oracle. All rights reserved.
Command Object
• Is used by:– Application- and applet-level menu items
– The application toolbar
• Is created with the Command Wizard in Siebel Tools– Select File > New Object > General > Command
Command Object
Reference
Commands and other object types are detailed in the Siebel Object Types Reference.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9a - 7
Copyright © 2009, Oracle. All rights reserved.
Command Objects and Business Service Methods
• Use the Command Wizard to specify the business service, method, and an input argument – Can also specify a bitmap to be used for a toolbar item
Command Objects and Business Service Methods
Method Arguments
Note that a command only allows you to pass a single argument string. If you need to pass multiple arguments, pass them in the argument field and then parse this string in your script.
Command Wizard
The diagram shows a step in the Command Wizard. The user enters a Business Service name, Method name, and a string argument to the method.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 9a - 8
Copyright © 2009, Oracle. All rights reserved.
Implementation Note: Calling a Server Business Service Method from a Browser Script
• Browser scripts are not allowed by default to call server business service methods for security reasons
• For each server business service called by a browser script, add a user property to the application– Set the application user property ClientBusinessServiceN to
the name of the server business service
Siebel Call Center
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Copyright © 2009, Oracle. All rights reserved.
Browser Script Techniques
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 2
Copyright © 2009, Oracle. All rights reserved.
Objectives
After completing this lesson, you should be able to:
• Create browser scripts
• Examine user interactions in browser scripts
• Use browser script debugging techniques
• List practices to avoid in browser scripts
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 3
Copyright © 2009, Oracle. All rights reserved.
What Is Different About Browser Scripts?
• Browser scripts are written in JavaScript– Similar to eScript, so you can use Siebel Tools' Script Editor
• Browser script executes in a user's browser, not in a Siebel AOM– Browser script code must be loaded on the Web server to be
available for use in a user's browser
– Different APIs are available for browser scripts than for server scripts
— Available APIs depend on High vs. Standard Interactivity mode
– Because browser script executes in a user session, scalability is a major performance concern
• Browser scripts are debugged and tested using different techniques– Siebel Tools does not include a browser script debugger
Browser Script
Reference
Browser scripts are discussed in Bookshelf's Siebel Object Interfaces Reference, "Browser Scripting".
Standard Interactivity Mode and Browser Scripts
If a Siebel application is running in Standard Interactivity mode, there is no means to interact with the Siebel Object Model as the framework is not loaded in the browser.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 4
Copyright © 2009, Oracle. All rights reserved.
Creating a Browser Script
• Add a browser script to an object definition in Siebel Tools– Right-click the object definition in the Object List Editor and
select Edit Browser Script
– Use the Script Editor to enter code— Script Assist features are not available
Enter browser script in the Siebel Tools Script Editor
Right-click object definition
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 5
Copyright © 2009, Oracle. All rights reserved.
Compiling Browser Scripts
• When the object definition that a browser script is associated with is compiled:– Siebel Tools generates a JavaScript source file (.js)
– Puts this file in a directory specified in View > Options > Scripting
View > Options > Scripting
Browser script is contained in a subdirectory named by
SRF version
Browser script source file
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 6
Copyright © 2009, Oracle. All rights reserved.
Compiling All Browser Scripts
• Siebel applications include a command-line tool, genbscript.exe, to compile all browser scripts– Located in …\siebsrvr\bin (Server) or …\Client\bin (Mobile
client)
• Parameters to genbscript are:– Configuration file (.cfg) for the application
– Destination directory for the .js files
– Language code
• Example: compile all browser scripts for Siebel Call Center (uagent.cfg) to …\client\public\enu for language code ENU
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 7
Copyright © 2009, Oracle. All rights reserved.
Deploying Browser Scripts to the Web Server
• To make browser scripts available on a user's browser, the scripts' source must be moved to the correct Web server directory:– Move the directory containing script source to:
— Siebel Server: …\siebsrvr\webmaster
— Siebel Mobile Web Client: …\Client\PUBLIC\<language code>— Mobile Web Client example: Copy the directory containing browser
scripts to D:\OUsea\Client\PUBLIC\enu
• To make new browser scripts available in user sessions, restart the Web server
Deploying Browser Scripts to the Web Server
Other Methods
There are two other methods of moving browsers scripts and making them available on the Web server:
• A Siebel Web administrator can refresh static files on the Web server by issuing a special Siebel Web Extensions (SWE) command:
http://host:port/application/start.swe?SWECmd=UpdateWebImages&SWEPassword=EnterpriseSecurityToken
where EnterpriseSecurityToken is a security token that allows administrative access to the Web server.
• Siebel Application Deployment Manager (ADM) can migrate data and files, including browser scripts, between one Siebel Enterprise and another. ADM could be used, for example, to migrate from a QA system to a Production system.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 8
Copyright © 2009, Oracle. All rights reserved.
APIs for Browser Scripting
• Two APIs are available for browser scripting:– Siebel Object Interfaces
– Document Object Model (DOM)
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 9
Copyright © 2009, Oracle. All rights reserved.
Siebel Object Interfaces for Browser Scripting
• Browser scripts support object events and methods for High Interactivity (HI) mode– Object methods and events are not available in Standard
Interactivity (SI) mode
• Object event examples:– Applet_PreInvokeMethod
– BusComp_PreSetFieldValue
• Object method examples:– TheApplication().GetService(): returns the business service
specified by name
– The Applet method FindControl(): returns a Control with a specified name
– The Control method GetProperty(): returns the value of a property of a control, such as a CheckBox or TextBox
Siebel Object Interfaces for Browser Scripting
Reference
Siebel object methods and events available for browser scripting are documented in the Siebel Object Interfaces Reference, "Browser Scripting". While the object events and methods for server and browser scripts overlap, some events and methods are only available in one type of script. O
racl
e U
nive
rsity
and
(Ora
cle
Cor
pora
tion)
use
onl
y.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 10
Copyright © 2009, Oracle. All rights reserved.
Document Object Model (DOM)
• Is a cross-platform, multi-language standard for representing and interacting with objects in HTML and XML files
• Allows programmatic manipulation of elements, such as images, text fields, and tables, on an HTML page
• The following sample HTML code swaps the image file when the user moves the mouse pointer over the image.<a href="http://someserver.com"
onMouseOver="document.logo.src='logo_over.gif'" onMouseOut="document.logo.src='logo_out.gif'">
<img src="logo_out.gif" name="logo"> </a>
Document Object Model (DOM)
DOM Standard
The DOM standard can be found at the World Wide Web Consortium web site: http://www.w3.org.
Example
The sample code sets up a hyperlink to the URL "http://someserver.com" and instead of providing hyperlink text, provides an image named "logo", which has initial source "logo_out.gif". The DOM code is in the onMouseover and onMouseout tags. The tags can be read: "On a mouseover of the link, set the object property document.logo.src to "logo_over.gif", and on mouseout, set the property to "logo_out.gif"".
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 11
Copyright © 2009, Oracle. All rights reserved.
Supported DOM Events
• Developers can write browser script using supported DOM controls and events– Available in high and standard interactivity modes
– Unsupported DOM events should not be scripted
• The supported DOM control events are:
XOnClick
XOnChange
XOnMouseOut
X
X
High Interactivity
OnMouseOver
OnBlur
OnFocus
DOM Event
X
X
X
Standard Interactivity
Supported DOM Events
The supported events for High Interactivity are onFocus and onBlur.
The supported events for Standard Interactivity are onFocus, onBlur, onMouseOver, onMouseOut, OnChange, and onClick. O
racl
e U
nive
rsity
and
(Ora
cle
Cor
pora
tion)
use
onl
y.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 12
Copyright © 2009, Oracle. All rights reserved.
Browser Script Techniques
• Common techniques used in browser script are:– User interaction and prompts
– Interaction with desktop applications
– Communications with a server script
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 13
Copyright © 2009, Oracle. All rights reserved.
User Interaction and Prompts
• Can range from simple dialog boxes to anything one can do with HTML and JavaScript
• Examples:– SWEAlert(): Display an informative dialog with an OK button
— Use SWEAlert() instead of alert()
– confirm(): Show a dialog with OK and Cancel buttons
– prompt(): Display a dialog with an input field and OK and Cancel buttons
– Open a new browser window
– Open a modal browser dialog using the Application ShowModalDialog() method
– Use Windows Script Host to display a Win32-style dialog (Yes/No/Cancel)
User Interaction and Prompts
JavaScript methods
alert(), confirm(), and prompt are JavaScript methods. SWEAlert() is a Siebel version of alert. alert() and SWEAlert() are both discussed on an upcoming slide.
Windows Script Host
Microsoft Windows Script Host is an automation technology for Microsoft Windows that provides scripting capabilities.
ShowModalDialog()
This Application method is documented in the Siebel Object Interfaces Reference.
Unified Messaging
Siebel Order Management includes a framework for displaying messages to users. Details on how to use this framework, Unified Messaging Framework (UMF), are found in the Siebel Order Management Infrastructure Guide.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 14
Copyright © 2009, Oracle. All rights reserved.
User Interaction Examples
TheApplication().SWEAlert("Error: the format of
field \"" + sFieldName + "\" is invalid. Please re-enter.");
var sResponse : chars =
prompt("What is your favorite color?", "Blue");
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 15
Copyright © 2009, Oracle. All rights reserved.
Interaction with Desktop Applications
• Example: When a user clicks a toolbar button, write selected records to MS Excel
Interaction with Desktop Applications
The screenshot shows a custom application toolbar button that executes a browser script, which opens a Microsoft Excel spreadsheet and populates it with Account data.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 16
Copyright © 2009, Oracle. All rights reserved.
Browser and Server Scripts
• Some problems require code split between browser and server scripts– Example: query for data based on the currently selected
record
• Browser script:– Initiates processing based on a UI event
– Handles all user interaction
– Invokes a server script
• Server script:– Queries for data and manipulates data
BrowserScript
ServerScript
Invoke
Return data
Siebel data
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 17
Copyright © 2009, Oracle. All rights reserved.
Communicating Between Browser and Server Scripts
• Methods to communicate between browser and server scripts include:– The browser script calls a server-side business service
— The server-side business service method passes data or messages back in an output property set
– The browser script uses InvokeMethod() on objects other than business service
— Example: Business Component InvokeMethod()
— Does not return data
– Use profile attributes to pass information between scripts— A profile attribute is user-specific data used in Personalization
— Use Application methods SetProfileAttr() and GetProfileAttr()— Can be called in browser and server scripts
Communicating Between Browser and Server Scripts
Profile Attributes Reference
Profile attributes are covered in detail in the Siebel Personalization Administration Guide, "Managing User Profiles".
Communication Using Profile Attributes
Attributes can be used to pass data and as flags signaling the completion of server-side processing. One technique is to poll an attribute value, which will be set on server script completion, in a browser script using setInterval(), a standard JavaScript function. setInterval() calls a function periodically after a specified delay.Example:
// call checkServerCompletion() every 1000 milliseconds
setInterval("checkServerCompletion()", 1000);
Note: polling, if done too frequently, can impact performance significantly.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 18
Copyright © 2009, Oracle. All rights reserved.
Testing and Debugging Browser Scripts
• Techniques for testing and debugging browser scripts are:– SWEAlert()
– Send debug statements to popup window
– Third party debugging tools
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 19
Copyright © 2009, Oracle. All rights reserved.
SWEAlert()
• Displays an informational message in the browser– Use for quickly diagnosing problems
– See the next slides for more robust debugging techniques
• Use SWEAlert() instead of alert()– SWEAlert() keeps focus even when popup windows, such as
pick applets or MVG applets, appear
• Example:TheApplication().SWEAlert("Error: the format of
field \"" + sFieldName + "\" is invalid. Please re-enter.");
SWEAlert()
The string passed as an argument in the example contains \" twice. This "escaped quote" is used to print a double quote in a string. For example, to prepare "word" for display (including the quotes) by a JavaScript function such as SWEAlert(), replace the quotes with \", which gives \"word\", and then surround this with double quotes:"\"word\"". O
racl
e U
nive
rsity
and
(Ora
cle
Cor
pora
tion)
use
onl
y.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 20
Copyright © 2009, Oracle. All rights reserved.
Popup Debug Window
• Is a user-created debugging facility that:– Centralizes debugging effort
– Is easy to turn off and on
– Is convenient to access:— No searching for debug files
— No interruptions responding to multiple alert boxes
Scrollable debug window contains information logged
from browser scripts
Popup Debug Window
Follow the steps described in the next slides to create and use this window.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 21
Copyright © 2009, Oracle. All rights reserved.
Creating a Popup Debug Window: Function Code
1. Create a browser-side function DebugWindow() in the Script Editor's general declarations section
function DebugWindow (sMessage){
// Set window properties (for MS IE only)
var strWinProp = "toolbar=no" + // Back, Forward, etc..",location=no" + // URL Field
",directories=no" + // "What's New", etc.",status=yes" + // Status bar at bottom",menubar=no" + // Menu bar at top of window",resizeable=yes" + // Allow resizing by dragging",scrollbars=yes" + // Allow scrolling",titlebar=yes" + // Enable titlebar resizing",width=200" + // Use screen.availWidth for full screen",height=200" + // Use screen.availHeight for full screen",top=100" + // Offset from top of screen",left=100" + // Offset from left side of screen",copyhistory=no" + // Don't add window to browser history"";
// open windowvar logwindow = window.open("", "Log", strWinProp);logwindow.focus();logwindow.document.write("<HEAD><TITLE>Debug Window</TITLE></HEAD><BODY>");// write messagelogwindow.document.write ("<font face=\"courier new\" color=\"0000ff\">"
+ sMessage + "</font><br>");
}
Creating a Popup Debug Window: Function Code
Enter the code shown on this slide to create a popup window suitable for debugging. This function opens a window with properties suitable for an IE Window, and then writes the parameter sMessage to the window.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 22
Copyright © 2009, Oracle. All rights reserved.
Creating a Popup Debug Window: Making the Function Available Globally
2. Make the function available within the browser script for the Application
– Example: Siebel Sales Enterprise application
– Define the function globally in the general declarations section of the Script Editor
Now any browser script running in the application can add a line to the popup debug window by calling:
top.DebugWindow("message");
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 23
Copyright © 2009, Oracle. All rights reserved.
Writing Debug Information to the Windowin Browser Scripts
3. Use the method in any browser script:
Write sMsg to debug window
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 24
Copyright © 2009, Oracle. All rights reserved.
Third-Party Script Debugger
• Enables developers to:– View source code of script being debugged
– Control pace of script execution— Set break-points
— Step through code
– View and change values of parameters and variables at run time
– Example: Microsoft Script Editor— Bundled with Microsoft Office 2003/XP
• Siebel applications do not include a browser script debugger
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 25
Copyright © 2009, Oracle. All rights reserved.
Pitfalls for Browser Scripts
• Avoid adding custom JavaScript to Web templates– Decreases reusability of templates
– Increases load time of Siebel Web pages
– May be overwritten during an upgrade
• Avoid scripting undocumented DOM objects and events– See Bookshelf's Siebel Object Interfaces Reference for a list
of supported objects and events
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 26
Copyright © 2009, Oracle. All rights reserved.
Pitfalls for Browser Scripting
• Do not modify any files located in:– Siebel Server:
— …/siebsrvr/WEBMASTER/<build#>/SCRIPTS
— …/SWEApp/public/enu/<build#>/SCRIPTS
– Mobile Web client:— …/Client/PUBLIC/enu/<build#>/SCRIPTS
– Changing these Siebel scripts:— May complicate the upgrade process
— May have a negative performance impact on the UI framework
— Will not be supported
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 27
Copyright © 2009, Oracle. All rights reserved.
Lesson Highlights
• Browser script is JavaScript code that executes in the browser at runtime– Is developed in Siebel Tools
– Can use the APIs— Siebel object events and methods (HI mode)
— DOM (HI and SI modes)
• Typical uses of browser script include:– Interacting with users with SWEAlert(), confirm(), prompt()
– Interacting with desktop applications
– Invoking server-side script
• Debug browser script with SWEAlert(), popup debug windows, and third-party debuggers
• Avoid modifying Siebel Framework files
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 10 - 28
Copyright © 2009, Oracle. All rights reserved.
Practice 10 Overview: Exploring User Notification
This practice covers the following topics:
• Explore different methods of user notification and interaction in browser scripts
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Copyright © 2009, Oracle. All rights reserved.
Measuring and Improving Script Performance
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 2
Copyright © 2009, Oracle. All rights reserved.
Objectives
After completing this lesson, you should be able to:
• Use the Siebel Script Performance Profiler to measure script performance
• Use SARM to measure script performance on a Siebel Server
• List best practices to optimize script performance
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 3
Copyright © 2009, Oracle. All rights reserved.
Scripting Performance
• Even a modest amount of scripting can have a dramatic, negative effect on a Siebel application’s:– Resource use, such as CPU utilization and memory footprint
– Key performance metrics, such as mean response time and scalability measures
• Keys to minimizing the impact of scripting on a Siebel application’s performance are:– Most importantly, minimize the amount of scripting!
– Measure and optimize scripts during development
– Follow Siebel scripting best practices— Developed based on the analysis of many customers’ scripts
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 4
Copyright © 2009, Oracle. All rights reserved.
Tools for Measuring Script Performance
• Siebel applications include two tools that allow you to measure script performance:– Siebel Script Performance Profiler
– Siebel Application Response Measurement (SARM)
• These two tools provide different, complementary looks at script execution:– Script Performance Profiler: measures the execution times
of the constituent functions of a single script— Can be used to optimize the script
– SARM: measures the total execution time of all scripts executing on a Siebel server
— Can be used to measure the overall impact of all scripts on Siebel application performance
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 5
Copyright © 2009, Oracle. All rights reserved.
Siebel Script Performance Profiler
• Siebel Tools’ scripting environment includes a Script Performance Profiler that allows you to:– Measure performance for all scripts that execute while the
client is running in Debug mode (/h flag)
– Identify script performance bottlenecks
– Track the time in each function, as well as on specific lines infunctions
– Export the profile data to a file
Siebel Script Performance Profiler
The Siebel Script Performance Profiler is new in Siebel 8.1.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 6
Copyright © 2009, Oracle. All rights reserved.
Starting the Script Performance Profiler
• In Siebel Tools, enable the Script Performance Profiler by:– Selecting View > Options
– Select the Debug tab
– Select the Enable Profiler checkbox
• In the Script Editor, open the profiler by selecting View > Profiler > Call Tree
Open the Profiler in Siebel Tools’
script editor
In the View > Options > Debug tab
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 7
Copyright © 2009, Oracle. All rights reserved.
Script Profiler Example
• This profile display shows the result of a server script that executes a query– The Profiler call tree shows multiple time measurements
Script call tree
Script Profiler Example
The Script Performance Profiler displays an expandable, hierarchical view of a script’s call tree. For each function (such as a user function or object method), the profile shows the number of calls to that function, the total time in the function, and the maximum and minimum time in any single function call. For example, the highlighted line is for the BusComp method GetBusComp(). This method is called in the WritePropertySet method of the LogViewInfo business service (the containing function, listed four lines above the highlighted line). GetBusComp() was called twice, for a total execution time of 94 ms, with maximum single execution of 94 ms and minimum of 0 ms.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 8
Copyright © 2009, Oracle. All rights reserved.
Optimizing with the Script Performance Profiler
• A general strategy for optimizing a script using the Script Performance Profiler is:– Profile the script for the most common execution scenarios
– Identify the functions with the greatest total execution time
– Focus your efforts on optimizing those functions— More leverage in optimizing functions that comprise the bulk of
total execution time
• Example: a script calls two functions, A and B– Total execution times:
— A = 10 calls at 2 ms each = 20 ms
— B = 3 calls at 25 ms each = 75 ms
• Techniques for optimizing functions are discussed later in this lesson
Optimizing B offers almost four times the
"leverage" as A
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 9
Copyright © 2009, Oracle. All rights reserved.
SARM
• Is a framework for capturing Siebel application performance data within the Siebel Server and the Siebel Web Server Extension (SWSE)
• Adheres closely to industry standards
• Includes post-processing tools for analyzing SARM data
Web Client
AOM
Siebel Gateway
NameServer
WebServer with
SWSE
SiebelFile
System
SiebelDatabase
Siebel Enterprise Server
SiebelServer
Collect performance data for Siebel Servers, Siebel
Web Servers, or both
SARM
ARM StandardSiebel ARM adheres closely to the Open Group’s ARM standard. Details of their standard can be found at their Web site: http://opengroup.org.
ReferenceFor more information on SARM, see Bookshelf’s Siebel Performance Tuning Guide, "Monitoring Siebel Application Performance with Siebel ARM".
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 10
Copyright © 2009, Oracle. All rights reserved.
SARM Output
• Is used to analyze how requests are executed and where time is spent during execution
• Assists in performance-tuning the application by allowing concrete measurement of Key Performance Indicators (KPIs)
SARM records contain detailed information about timing, CPU usage, and memory usage. These
records assist in performance-tuning the application
SARM Output
Diagram
The screenshot shows a report that displays SARM data. This data includes response time, CPU time used, memory usage, and instance name (such as which business service executed, as shown).
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 11
Copyright © 2009, Oracle. All rights reserved.
SARM Areas
• Data collected by SARM is categorized into areas
• Example areas:
Time duration spent in any eScript scriptseScripts
Time duration for any Siebel database-layer callsDatabase Time
Siebel Server Time
Infra Network Time
Web Server Time
Area
Time duration a request has spent on the Web server
Time duration for the request to be processed by the Siebel Server and Database Server
Time duration between a request from the Web server and the Siebel Server
Description
SARM Areas
Table
The table shows different SARM areas, including:• Web Server Time: amount of time a request spent on the Web server.• Infra Network Time: time between a request from the Web server and the Siebel Server• Siebel Server Time: Time spent processing the request by the Siebel Server and Database
Server• Database Time: duration of any database-layer calls• eScripts: time spent in any eScript calls
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 12
Copyright © 2009, Oracle. All rights reserved.
Collecting Data With SARM
• The high-level steps for collecting SARM data are:– Enable SARM for a Siebel Server or server component(s)
— Set the SARM Granularity Level parameter to 1 or 2— 1: Gives general performance data
— 2: Gives more detailed performance data
– Optionally, set additional SARM parameters— Examples:
— Log Directory
— SARM Period: minutes between buffer flushes
— SARM Users: comma-delimited list of users whose sessions will be monitored
– Run the baseline, unmodified Siebel application
– Run the configured and scripted Siebel application
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 13
Copyright © 2009, Oracle. All rights reserved.
Analyzing SARM Data
• Use SARMQuery to analyze SARM data– SARMQuery is an advanced command-line tool for analyzing
SARM files
• Invoke SARMQuery with input and options– Input may be files, directories, or standard input
– Using no options provides a short help listRun SARMQuery with no options to get a brief list of helpful commands
Analyzing SARM Data
Details on using SARMQuery are in Bookshelf’s Siebel Performance Tuning Guide.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 14
Copyright © 2009, Oracle. All rights reserved.
Executing SARMQuery Commands
• SARMQuery provides a wide range of options to produce exactly the desired results– Filter and aggregate input data
– Specify the format of output data
– Produce reusable macros to speed up future queries
• Enter SARMQuery -help for a complete list of option flags
• Example query command: – Return any records that invoke a script that takes longer than
one second to execute
sarmquery –select area=script –select resptime=1000–select tree=all –input .
1. Select records from the script area
2. Filter on scripts that take longer than 1000 ms
3. Include all areas in the script area tree
Executing SARMQuery Commands
Filtering Data Reference
For a complete list of select options, see the table of "Header Filters for the Siebel ARM Query Tool" in the Siebel Performance Tuning Guide.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 15
Copyright © 2009, Oracle. All rights reserved.
General Optimization Techniques
• General rules to reduce time spent in a scripted function:– Move unnecessary code out of long loops
– Consider using "inline" code instead of a short function— Calling a function incurs overhead
— Tradeoff: putting code in a function improves script readabilityand maintainability, but can slow performance
— Example:maxValue = (a > b) ? a : b; /* inline code */
maxValue = myMax(a,b); /* short user function */
– Become familiar with the built-in functions— eScript offers many functions for buffer manipulation, directory
and file manipulation, data handling, type conversion, and otheruses
— See Bookshelf’s Siebel eScript Language Reference for a full description of built-in functions
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 16
Copyright © 2009, Oracle. All rights reserved.
Siebel Scripting Performance Recommendations
• Best practices for Siebel scripts based on customer experiences include:– Do not script BusComp_PreGetFieldValue
– Minimize browser to server roundtrips
– Use indexed columns in queries
– Use the correct cursor mode in queries
– Avoid setting Force Active to TRUE for BC fields
– Remove debugging code for production
– Use primitive data types
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 17
Copyright © 2009, Oracle. All rights reserved.
Do Not Script BusComp_PreGetFieldValue
• The BusComp_PreGetFieldValue event occurs for every field that is retrieved in a SQL SELECT statement– Occurs very frequently
• Any script in this event causes a severe penalty in performance– Oracle has had many customers with severe performance
problems attributed exclusively to scripting this one event
• This event handler shouldn’t need scripting– Alternatives are available for typical uses, such as data
validation— Covered in a prior lesson
Do Not Script BusComp_PreGetFieldValue
If an applet has 20 list columns, then the BusComp_PreGetFieldValue handler will fire 20 times for each record. This can slow your Siebel application significantly!
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 18
Copyright © 2009, Oracle. All rights reserved.
Minimize Browser to Server Roundtrips
• In browser scripts, these are caused by:– Referencing Profile Attributes
– Calling Server-Side Business Services
– Using the "Immediate Post Changes" field property
Browser script running in Siebel client calls a server business service method
Method invocation and return of output requires
a roundtrip to server
Minimize Browser to Server Roundtrips
Diagram
The diagram depicts a browser script calling a server business service method and then receiving output arguments from the server. This is an example of a server round-trip.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 19
Copyright © 2009, Oracle. All rights reserved.
Use Indexed Columns For Searching
• Scripts should use indexed columns in search and sort specifications– Use Siebel Tools to determine indexed columns
• Failure to use indexed columns in search and sort specifications leads to queries that use temporary tables or produce sequential table scans– Results in dramatically worse performance
Use Siebel Tools to determine which table columns are
indexedIndexes for a table
Columns that are indexed
Use Indexed Columns For Searching
Diagram
The screenshot shows the Object Explorer in Siebel Tools. The Table type is shown, as well as its Index child object type, which specifies indexes defined for the table, and a grandchild object type, Index Column, which shows which columns are indexed. O
racl
e U
nive
rsity
and
(Ora
cle
Cor
pora
tion)
use
onl
y.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 20
Copyright © 2009, Oracle. All rights reserved.
Use The Correct Cursor Mode
• For the ExecuteQuery() method, use the ForwardOnly cursor mode wherever possible– Improves performance
– Can only traverse forward from first to last record
– Does not create a buffer to hold records when they have been scrolled past
– Does not have to keep a linked list up to date when scrolling through record set
• Only use ForwardBackward when required:– Need to support record set navigation in both directions
– Using DB2 UDB for z/OS and OS/390 (Siebel Tech Note 592)
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 21
Copyright © 2009, Oracle. All rights reserved.
Avoid Setting Force Active to TRUE for BC Fields
• Setting a business component field’s Force Active property to True can cause performance issues in both configuration and script– Especially true for Joined and Multi-valued fields
• Force Active will often not be needed, because a business component field is already active if:– It is exposed and visible on the currently displayed applet
– Its Link Specification property is set to TRUE
– Its Force Active property is set to TRUE
– Its Business component's Force Active property is set to TRUE
– It is used in a search or sort specification
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 22
Copyright © 2009, Oracle. All rights reserved.
Remove Debugging Code
• Debugging code should be removed before going into production– Some debugging code can be commented out effectively
— Example: comment out TraceOn(), Trace(), and TraceOff() calls
– However, large amounts of commented code can affect code maintainability
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 23
Copyright © 2009, Oracle. All rights reserved.
Use Primitive Data Types
• Use primitive data types instead of constructed types– Operations on primitive types offer better performance
Boolean
Number
String
Instead of using…
chars
bool
float
Use this primitive
Use Primitive Data Types
Table
The table advises:• Using the char primitive type rather than String• Using the float primitive type rather than Number• Using the bool primitive type rather than Boolean
There may be compelling reasons to use the derived type, despite the primitive type‘s better performance. For example, you may want to use methods available for the String type, such as split(), match(), or search().
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 24
Copyright © 2009, Oracle. All rights reserved.
Lesson Highlights
• Siebel applications include two tools to measure scripting performance:– Script Performance Profiler allows you to measure single
script execution in great detail
– SARM allows you to measure the total impact of scripting on your Siebel Server
• Best practices for good scripting performance include:– Do not script BusComp_PreGetFieldValue
– Minimize browser to server roundtrips
– Use indexed columns in queries
– Use the correct cursor mode in queries
– Remove debugging code for production
– Use primitive data types
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting 11 - 25
Copyright © 2009, Oracle. All rights reserved.
Practice 11 Overview: Measuring Scripting Performance
This practice covers the following topics:
• Use the Script Performance Profiler
• Use SARM to measure scripting impact on a Siebel Server
• Observe why BusComp_PreGetFieldValue event should not be scripted
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Copyright © 2009, Oracle. All rights reserved.
Siebel eScript Programming
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting A - 2
Copyright © 2009, Oracle. All rights reserved.
Objectives
After completing this lesson, you should be able to:
• Use eScript data types
• Use common eScript control structures
• Create eScript variables and functions
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting A - 3
Copyright © 2009, Oracle. All rights reserved.
Siebel eScript
• Is interpreted by the Siebel Object Manager at runtime
• Is ECMAScript compliant:– ECMAScript is a standardized implementation of JavaScript
– You can migrate standard ECMAScript code to Siebel eScript with minimal effort
• Supports all debugging and profiling features in the Siebel Tools Script Editor– Scripts using Siebel Visual Basic can only use a subset of
these features
• eScript is recommended for new scripts
Siebel eScript
Reference
eScript programming is covered in detail in the Siebel eScript Language Reference.
ECMAScript
ECMAScript is the standard implementation of JavaScript as defined by the ECMA-262 standard. The Siebel ST eScript engine supports ECMAScript Edition 4. Documentation for the ECMAScript standard can be found at http://www.ecma-international.org/default.htm.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting A - 4
Copyright © 2009, Oracle. All rights reserved.
eScript Programming
These topics are basic to programming in Siebel eScript:
• Valid identifiers
• Whitespace and special characters
• Comments
• Data types
• Variable declarations
• Function definitions
• Function calls
• Control structures
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting A - 5
Copyright © 2009, Oracle. All rights reserved.
Valid Identifiers
• Identifiers, such as variable and function names, are:– Case-sensitive
— Example: a variable named Sum differs from one named sum– Are made up with uppercase and lowercase ASCII letters,
digits, _, and $
– Must start with a letter, _, or $
– Must not conflict with eScript keywords, such as if, return, typeof, and so on
• Examples: valid or invalid?– MyFlag
– 2Flag
– D&B_Flag
– __debugFlag
Valid Identifiers
Examples
Valid or invalid?• MyFlag is valid• 2Flag is invalid, because an identifier must start with a letter, _, or $.• D&B_Flag is invalid, because "&" cannot be used in an identifier.• __debugFlag is valid. An identifier can start with _.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting A - 6
Copyright © 2009, Oracle. All rights reserved.
Whitespace Characters
• The eScript interpreter uses whitespace characters to separate text– Whitespace characters are space, tab, linefeed, and carriage
return
– All combinations of whitespace characters are treated the same by the eScript interpreter
– Example: the following instructions are treated the samesum=a+b;
sum = a + b;
sum = a + b;
sum = a +
b;
• Use whitespace characters to make your code more readable
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting A - 7
Copyright © 2009, Oracle. All rights reserved.
Special Characters
• Some characters have a special meaning to the eScript interpreter, such as &, ", ‘, and \
• To use these special characters in a string, you must "escape" them by preceding them with a backslash \
• Examples:
"D:\\images\\img.jpg"
"\"string\""
"D\&B Industry"
String
D&B Industry
D:\images\img.jpg
"string"
Interpreted As
Special Characters
Escape Sequences
For a complete listing of escape sequences, see the Siebel eScript Language Reference, "Siebel eScript Commands: String Objects".
Examples
The string "D\&B Industry" is interpreted as "D&B Industry" because \& is the escape sequence for &.The string "\"string\"" is interpreted as "string" (with quotes), because the escape sequence \" is replaced by ".The string "D:\\images\\img.jpg" is interpreted with single back-slashes, because \\ is the escape sequence for \.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting A - 8
Copyright © 2009, Oracle. All rights reserved.
Comments
• eScript supports two types of comments:– Double slashes (//) marks the rest of the line as a comment
– All text between /* and the next */ is marked as a comment
• Use comments to document your code
• Comment examples (comments in green):sum = arg1 + arg2; // sum arguments
// This entire line is a comment
/* A comment block extending to multiple lines.
Note how the alignment enhances readability.
*/
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting A - 9
Copyright © 2009, Oracle. All rights reserved.
Data Types
• Siebel eScript defines two categories of data types:– Primitive data types don’t have any properties or functions
that are part of the data type definition
– Object data types have associated properties and functions
• Primitive data types in eScript are:– chars: a sequence of alphanumeric characters
– float: a floating point number, which can also be used for integer values
— Some functions that require an integer argument do conversion from float internally
– bool: either true or false
Data Types
chars
To be precise, a chars variable is a sequence of unsigned 16-bit values.
Undefined
Undefined is another, less-used primitive type. It is the type of any variable without an explicit type declaration.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting A - 10
Copyright © 2009, Oracle. All rights reserved.
Data Types: Object Data Types
• Object data types have functions (methods) and values (properties) defined for them
• Example: a String consists of:– A sequence of alphanumeric characters
– A value (property), Length
– Methods, such as:— substring (start, end): returns a substring of a String object
— charAt (position): returns the character at a given position within a String
— split (delimiter): returns an array of substrings created by splitting the String at a specified delimiter
• Object data types in eScript include Siebel object types (Applet, Application, BusComp, and so on) and general types (Array, String, Buffer, RegExp, Date, and so on)
Data Types: Object Data Types
Reference
See the Siebel eScript Language Reference for a complete list of supported data types.
Primitive versus Object Data Types
When you have a choice between using a primitive data type and an object data type, prefer the primitive type, as it will offer better performance. For example, use chars instead of String where possible.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting A - 11
Copyright © 2009, Oracle. All rights reserved.
Variable Declarations
• Variables must be defined explicitly before use in eScript using the var keyword
• Optionally, declare the data type– Type information is used by the Siebel Script Editor and
debugger
– Makes code more readable and easier to debug
• Examples:var test; // Undefined type
var typedVar : chars = "abc"; // typed declaration
var oBC : BusComp; // another typed declaration
Variable Declarations
eScript versus ECMAScript
A variable does not have to be explicitly declared in ECMAScript, but does have to be in Siebel eScript.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting A - 12
Copyright © 2009, Oracle. All rights reserved.
Variable Definitions: Variable Scope
• A variable defined within a function has local scope– It only exists while the function is executing
• A variable defined outside of any function has global scope– It is available across code modules
• Example:var globalVar : float = 42.0;function myFunc(){
var localVar : chars = "hello";…
}
• Recommendation: avoid global variables when possible– A global variable can be used in many places: hard to debug
and effects of changing it are global
Variable Definitions: Variable Scope
Variables can also be defined within a for() loop. Such variables only have scope within the loop.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting A - 13
Copyright © 2009, Oracle. All rights reserved.
Function Definitions
• A function is:– A block of code that can be passed parameters
– Global in scope
• Functions are considered a special data type by eScript:– Can use any valid variable name (alphanumeric, $, and _)
– Are declared with the function keyword, instead of var– Have a special operator ( ) to allow function evaluation and
argument passing
• Define the function body in a block of code after the function is declaredfunction mySum (arg1: float, arg2: float) : float
{
return (arg1 + arg2);
}
Defining Functions
The arguments[] property
A function has a property, arguments[], consisting of an array of argument values. This property can be used to programmatically access function parameters. The following example shows a function that sums its arguments using arguments [].function sumAll(){
var total = 0;for (var argnum=0; argnum<sumAll.arguments.length; argnum++){
total += sumAll.arguments[argnum];}return total;
}
Note that the arguments array has a length property.
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting A - 14
Copyright © 2009, Oracle. All rights reserved.
Function Calls
• eScript uses "object-oriented-like" syntax for function calls:<object>.<function>(<args>)
– Examples: — stringVar.split(" ") calls the split function for variable stringVar
and passes the argument " "
— stringVar.substring (2, 4) calls the substring function for the variable stringVar and passes arguments 2 and 4
– To access object properties, use similar syntax: <object>.<property>
— Example: stringVar.length is the length property for stringVar
• Even when a function takes no arguments, use parentheses to call– Differs from ECMAScript requirements
Calling Functions
Examples
split() is used to break a String object into tokens separated by a delimiter (" ", equals space, in this example). substring() takes two arguments: the starting location within the string and the ending location plus one, and returns the string between those locations. For example, if strVar = "abcdefg", then strVar.substring(2, 4) equals "cd". Note that strings start at index 0
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting A - 15
Copyright © 2009, Oracle. All rights reserved.
Function Calls: Pass by Value or Reference
• Input arguments can be passed to a function in two ways:– By value (the default):
— A copy of an argument’s value is provided to the function
— The argument is unchanged as a result of the function call
– By reference:— Uses & before the variable name to indicate pass by reference
— A reference to the input variable is passed to the function
— The value of the input variable may be changed by the function
• Example: var arg1 : float = 5.0;
var arg2 : float = 3.0;
var arg3 : float = 42.0;
myAdd (arg1, arg2); // call by value
myAdd (arg1, &arg3); // call by reference; arg3 may change
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting A - 16
Copyright © 2009, Oracle. All rights reserved.
Control Structures
• eScript supports common control structures, such as:– do… while loop
do{ // block of code }while (condition)
– for loopfor (var count = 0;count>=maxCount;count++)
{ // block of code repeated in loop}
– if statementif (condition)
{ // block of code}
else if (another condition)
{// different block code}
else
{// yet another block of code}
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting A - 17
Copyright © 2009, Oracle. All rights reserved.
Control Structures: Switch Statement
• A switch statement can be used to select between different values of a variable– Includes a "fall-through" case that can be used to catch
erroneous values
• Example:switch (MethodName){
case "Add": // call myAdd
myAdd(Inputs, Outputs);
break;
case "Subtract": // call mySubtractmySubtract(Inputs, Outputs);
break;
default: // other values
break;
}
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.
Siebel 8.1.x Scripting A - 18
Copyright © 2009, Oracle. All rights reserved.
Lesson Highlights
• The Siebel ST eScript engine provides strong typing and enhanced Script Editor and debugging support
• eScript provides primitive and object data types– Primitives are chars, float, bool, and Undefined
– Object data types include Siebel and general-purpose types
• Variables can be local or global scope– Recommendation: avoid global variables
• Functions are of global scope
• eScript offers standard control structures:– do… while()
– for() loops
– if ( ) … else
– switch()
Ora
cle
Uni
vers
ity a
nd (O
racl
e C
orpo
ratio
n) u
se o
nly.
Thes
e eK
it m
ater
ials
are
to b
e us
ed O
NLY
by
you
for t
he e
xpre
ss p
urpo
se S
ELF
STU
DY.
SH
ARIN
G T
HE
FILE
IS S
TRIC
TLY
PRO
HIB
ITED
.