Siebel Business Process Framework: Task UI Guide > Options for Building a Task UI > Starting a Task UI >

Defining a Script to Start a Task UI


You can use a browser script or a server script to start a task UI. Your script calls the Task UI Service business service, then calls the LaunchTaskFromScript business service method to start a task, passing in the name of the task. The script must be compiled into proxy JavaScript objects or into the SRF. Processing varies depending on whether browser or server script is involved, according to the following logic:

  • Browser script. The InvokeMethods for a script is first handled on the client objects, then is passed to their server equivalents. There is no check for CanInvokeMethod.
  • Server script. JavaScript files that contain the scripted methods are compiled into the SRF, then called from the Object Manager at the appropriate pre or post event. There is no check for CanInvokeMethod.

At run time, the Task UI Service examines the name of the task UI and makes sure the user possesses the license and responsibility to run the task. If the user is allowed to run the task, then the service passes the pointer of the active business component to the Task Controller, designating it as the context business component. If the task requires a business component that is not the same as the context business component, then the task controller throws an error. Also, if the task is not activated, then the task controller throws an error. Otherwise, the task runs, and the task pane opens.

Note the following restrictions when using a script with a task UI:

  • Calling a task UI from a script requires UI context, meaning that a record in an applet can be referenced. Do not start a task from a script that does not include UI context, such as a script for a workflow process, or from an event where the UI did not finish processing, such as Applet_Load.
  • A script can only pass the name of the task UI. No other parameters can be passed.
  • A script can only be used to start a task UI. It is not possible for a script to interact with a task in any other way than to start the task.

Example Client Script

In this example, the browser script looks for the task UI named Create a Contact, then starts the task:

function Applet_PreInvokeMethod (name, inputPropSet)
{

try
{

if (name == "Test")
{

var inputPropSet;
var outputPropSet;
var taskUIsvc;

inputPropSet = theApplication().NewPropertySet();

outputPropSet = theApplication().NewPropertySet();

taskUIsvc = theApplication().GetService("Task UI Service (SWE)");

inputPropSet.SetProperty("TaskName","Create a Contact");

<!-- Note: because taskUIsvc.Invokemethod() is required to pass outputPropSet, the outputPropSet is created. outputPropSet is not used to send results back to the task UI--!>

taskUIsvc.InvokeMethod("LaunchTaskFromScript",inputPropSet,outputPropSet);

return ("CancelOperation");

}

}

catch(e)
{

theApplication().alert("Error" + e.toString());

}

finally
{
}

return ("ContinueOperation");

}

Example Server Script

This example illustrates how server script can be used to launch a task UI named Create a Contact:

function WebApplet_PreInvokeMethod (MethodName)
{

try
{

if (MethodName == "Test")
{

var inputPropSet;
var outputPropSet;
var taskUIsvc;

inputPropSet = TheApplication().NewPropertySet();

outputPropSet = TheApplication().NewPropertySet();

taskUIsvc = TheApplication().GetService("Task UI Service (SWE)");

inputPropSet.SetProperty("TaskName","Create a Contact");

<!-- Note: because taskUIsvc.Invokemethod() is required to pass outputPropSet, the outputPropSet is created. outputPropSet is not used to send results back to the task UI--!>

taskUIsvc.InvokeMethod("LaunchTaskFromScript",inputPropSet,outputPropSet);

return (CancelOperation);

}

}

catch(e)
{

TheApplication().RaiseErrorText("Error" + e.toString());

}

finally
{
}

return (ContinueOperation);

}

Siebel Business Process Framework: Task UI Guide Copyright © 2009, Oracle and/or its affiliates. All rights reserved. Legal Notices.