Siebel Business Process Framework: Task UI Guide > Configuring Task UI >

Writing Scripts to Instantiate Tasks


You can use browser and server scripts to instantiate tasks. Your script calls the Task UI Service business service and invokes the method LaunchTaskFromScript to start a task, passing in the task name. The script must be compiled into proxy JavaScript objects or into the SRF.

Browser scripts. The InvokeMethods for scripts are first handled on the client-side objects, and then passed to their server-side equivalents. There is no CanInvokeMethod check.

Server scripts. If on the server-side, JavaScript files containing the scripted methods are compiled into the SRF, and then called from the OM at the appropriate pre- or postevent, there is no CanInvokeMethod check.

At run time, the Task UI Service checks the task name and checks that the user has the license and responsibility to run the task.

NOTE:  Its important to understand that the ability to call tasks from scripts requires UI context. Do not invoke tasks from scripts that do not have UI context (for example, workflow scripts) or from events where the UI has not finished processing (for example, Applet_Load).

Sample Client-Side Script

In this example, the browser script looks for the task called Create a Contact and launches it.

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");

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

return ("CancelOperation");

}

}

catch(e)
{

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

}

finally
{
}

return ("ContinueOperation");

}

Sample Server-Side Script

This example shows the server script approach to launch a task called 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");

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 © 2006, Oracle. All rights reserved.