Using Siebel Tools > Siebel Script Editors >

Using Script Libraries


Script libraries are a component of the ST eScript Engine that provide a framework for invoking methods on business services from within the scripting interface. However, only cached services that are marked for external use can be used as a script library. Methods on a newly-created service library are available only after the new service is saved in Siebel Tools.

This topic describes how to make custom methods available to a business service script library and how to invoke these methods on the script library.

NOTE:  Using script libraries is optional. All code written before Siebel 8.0 is still supported.

For more information about script libraries, see Siebel eScript Language Reference.

Creating Custom Methods and Making Them Available in a Script Library

Use the following procedure to create a custom method and make it available in a script library.

To create a custom method and make it available in a script library

  1. Create a business service method script in Siebel Tools.
  2. Ensure the script does not contain compilation errors.
  3. Save the business service method script.
  4. Check the External Use flag for the business service object.

The custom method for the service is added to the script library and can be displayed in the Script Assist utility.

Invoking Custom Methods Using a Script Library

After you make a business service available for external use in Siebel Tools, you can then invoke methods on the service from other scripts using the script library framework. The available methods in a script library also appear in the Script Assist window. For more information about Script Assist, see Using Script Assist.

Use the following procedure to invoke a custom method using a script library.

To invoke a method using a script library

  1. Make sure the Enable Method Listing and Enable Auto Complete fields are checked in the Siebel Tools scripting options.

    For information on setting these options, see Setting Script Assist Preferences.

  2. In the script editor, type the name of a business service object followed by a period (.).

    All the default and custom scripted methods available for the business service object appear.

  3. Select the method that you want to add to your script.

    NOTE:  You may want to run a syntax check to detect incorrect method calls. For more information about checking syntax, see Checking Syntax.

Example of Using a Script Library

The following is one example of using a script library to invoke a custom method. You may use the feature differently, depending on your business model.

Given you have a mathService business service marked for external use with a scripted method named square (x):

function square (x)
{
return (x * x);
}

NOTE:  For functions called using script libraries, the compiler checks that argument types are valid and do not contain incompatibilities.

You can invoke this method using another script by typing the following:

var oBS: Service = TheApplication().GetService ("mathService");
var value = 10;
var square_value = oBS.square (value);

To see a list of the available methods for the mathService library (as shown in Figure 29), type the following:

var square_value = oBS.

Figure 29. Example of a Script Assist Window Showing the Methods Called from a Script Library
Click for full size image
Using Siebel Tools Copyright © 2007, Oracle. All rights reserved.