`
huobengle
  • 浏览: 858644 次
文章分类
社区版块
存档分类
最新评论

Siebel Tools: How To Invoke Script from a Siebel Button At the Business Component and Applet Levels

 
阅读更多

How To Invoke Script from a Siebel Button At the Business Component and Applet Levels

Joshua Weir posted 1/22/2009 |

This article describes the steps required to configure Siebel to invoke Siebel eScript code from a button.

You can invoke siebel script from a button through business component server script, applet server script and applet browser script. The following is an explanation of how to do this. For these examples I will assume that you have configured the button and this is displayed on the desired applet. If you dont know how to configure a button using Siebel Tools refer to the Siebel Bookshelf - Configuration eBusiness Applications.

For all examples below you need to configure the button in Siebel Tools to call a custom method. In Siebel Tools Object Explorer, navigate to Applet > Control, for the applet you have configured the button on. In the Controls list applet update the Method Invoked field to have value: TestMethod.

TestMethod will be the custom method that is invoked when the button is clicked. You will execute code when this method is invoked.

Now to execute script when the button is clicked we need to add code to the PreInvokeMethod event script of the Business Component/Applet and execute the code only if the Method Invoked = TestMethod. We need to ensure that we return CancelOperation if the custom TestMethod is invoked, because this is a custom method, if we return ContinueOperation then Siebel would error as the Siebel C++ internal code does not know what that method is. For more information on this, see my post about CancelOperation and ContinueOperation:

Siebel Scripting: CancelOperation or ContinueOperation?

Below are the code examples. Note that for each of these examples, I am executing code to create and populate text into a text file called Test.log. This is acheived through code similar to the following:

TheApplication().TraceOn("Test.log","Allocation","All");

TheApplication().Trace("This is text in Test.log");

TheApplication().TraceOff();

As I have not specified a path for the Test.log file in the code, the file will be created in the default location which is the bin directory. Eg. D:/siebel/webclient/bin.

There are code examples below for the following cases:

1. Invoke Applet Server Script from a Button
2. Invoke Applet Browser Script from a Button
3. Invoke Business Component Script from a Button
4. Invoke Applet Browser Script, Applet Server Script and Business Component Server Scripts from a Single Button Click

Invoke Applet Server Script from a Button

Here is the code added to the PreCanInvokeMethod method of the applet server script:

function WebApplet_PreCanInvokeMethod (MethodName, &CanInvoke)

{

var retval = ContinueOperation;

try {

if ( MethodName == "TestMethod" )

{

CanInvoke = "TRUE";

retval = CancelOperation;

}

}

catch(e)

{

retval = CancelOperation;

TheApplication().RaiseErrorText(e.toString());

}

finally

{

}

return (retval);

}

Here is the code added to the PreInvokeMethod method of the applet server script:

function WebApplet_PreInvokeMethod (MethodName)

{

var retval = ContinueOperation;

try {

if ( MethodName == "TestMethod" )

{

retval = CancelOperation;

TheApplication().TraceOn("Test.log","Allocation","All");

TheApplication().Trace("Executing Applet Server Script!");

TheApplication().TraceOff();

}

}

catch(e)

{

retval = CancelOperation;

TheApplication().RaiseErrorText(e.toString());

}

finally

{

}

return (retval);

}

Now if you compile the applet, run the application and click the button a file Test.log will be created in the bin directory containing text "Executing Applet Server Script!".

Invoke Applet Browser Script from a Button

Here is the code added to the PreCanInvokeMethod method of the applet server script:

function WebApplet_PreCanInvokeMethod (MethodName, &CanInvoke)

{

var retval = ContinueOperation;

try {

if ( MethodName == "TestMethod" )

{

CanInvoke = "TRUE";

retval = CancelOperation;

}

}

catch(e)

{

retval = CancelOperation;

TheApplication().RaiseErrorText(e.toString());

}

finally

{

}

return (retval);

}

Here is the code added to the PreInvokeMethod method of the applet browser script:

function Applet_PreInvokeMethod (name, inputPropSet)

{

var retval = "ContinueOperation";

try {

if ( name == "TestMethod" )

{

retval = "CancelOperation";

alert("Executing Applet Browser Script!");

}

}

catch(e)

{

alert("Error in preinvokemethod event of " + this.Name() + "/n" +

e.toString() + " " + e.message + "/n" +

"Error Code: " + (e.number & 0xFFFF));

retval = "CancelOperation";

throw(e);

}

finally

{

}

return (retval);

}

Now if you compile the applet, generate browser scripts, run the application and click the button an alert message box will be displayed containing text "Executing Applet Browser Script!".

Invoke Business Component Server Script from a Button

Here is the code added to the PreCanInvokeMethod method of the applet server script:

function WebApplet_PreCanInvokeMethod (MethodName, &CanInvoke)

{

var retval = ContinueOperation;

try {

if ( MethodName == "TestMethod" )

{

CanInvoke = "TRUE";

retval = CancelOperation;

}

}

catch(e)

{

retval = CancelOperation;

TheApplication().RaiseErrorText(e.toString());

}

finally

{

}

return (retval);

}

In Siebel Tools, navigate to the Business Component that the applet is based on. Here is the PreInvokeMethod script for the Business Component:

function BusComp_PreInvokeMethod (MethodName)

{

var retval = ContinueOperation;

try {

if (MethodName == "TestMethod")

{

retval = CancelOperation;

TheApplication().TraceOn("TestBC.log","Allocation","All");

TheApplication().Trace("Executing Business Component Script!");

TheApplication().TraceOff();

}

}

catch(e)

{

retval = CancelOperation;

TheApplication().RaiseErrorText(e.toString());

}

finally

{

}

return (retval);

}

Now if you compile the applet and business component, run the application and click the button a file TestBC.log will be created in the bin directory containing text "Executing Business Component Server Script!".

Invoke Applet Browser Script, Applet Server Script and Business Component Server Scripts from a Single Button Click

Here is the code added to the PreCanInvokeMethod method of the applet server script:

function WebApplet_PreCanInvokeMethod (MethodName, &CanInvoke)

{

var retval = ContinueOperation;

try {

if ( MethodName == "TestMethod" )

{

CanInvoke = "TRUE";

retval = CancelOperation;

}

}

catch(e)

{

retval = CancelOperation;

TheApplication().RaiseErrorText(e.toString());

}

finally

{

}

return (retval);

}

Here is the code added to the PreInvokeMethod method of the applet server script:

function WebApplet_PreInvokeMethod (MethodName)

{

var retval = ContinueOperation;

try {

if ( MethodName == "TestMethod" )

{

TheApplication().TraceOn("Test.log","Allocation","All");

TheApplication().Trace("Executing Applet Server Script!");

TheApplication().TraceOff();

}

}

catch(e)

{

retval = CancelOperation;

TheApplication().RaiseErrorText(e.toString());

}

finally

{

}

return (retval);

}

In Siebel Tools, navigate to the Business Component that the applet is based on. Here is the PreInvokeMethod script for the Business Component:

function BusComp_PreInvokeMethod (MethodName)

{

var retval = ContinueOperation;

try {

if (MethodName == "TestMethod")

{

retval = CancelOperation;

TheApplication().TraceOn("TestBC.log","Allocation","All");

TheApplication().Trace("Executing Business Component Script!");

TheApplication().TraceOff();

}

}

catch(e)

{

retval = CancelOperation;

TheApplication().RaiseErrorText(e.toString());

}

finally

{

}

return (retval);

}

Now if you compile the applet and business component, generate browser scripts, run the application and click the button the following will occur:

1. The applet browser script will execute first displaying an alert message box containing text "Executing Applet Browser Script!".

2. The applet server script will then execute writing to file Test.log in the bin directory containing text "Executing Applet Server Script!".

3. The business component server script will then execute writing to file TestBC.log in the bin directory containing text "Executing Business Component Script!".

So the order of script execution for siebel applets and business components are as such:

Applet Browser Script -> Applet Server Script -> Business Component Server Script

Notice that the applet browser script and applet server script no longer returns CancelOperation, it returns ContinueOperation, this allows the script to be executed in following event methods. Eg. If we returned CancelOperation on the Applet Server Script in the above example the Business Component script would not have executed.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics