Siebel Business Process Framework: Task UI Guide > Customizing Task UI > Starting a Task UI >

Creating 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. It then passes the name of the task UI to the LaunchTaskFromScript business service method to start the task UI. You must compile the script into proxy JavaScript objects or to the SRF (Siebel Repository File). Processing varies depending the following type of script you use:

  • Browser script. Siebel CRM handles the InvokeMethod methods for a script on the client objects, and then passes them to their server equivalents.
  • Server script. Siebel CRM compiles the JavaScript files that include the scripted methods to the SRF, and then calls them from the Object Manager at the required preevent or postevent.

In this situation, browser script or server script does not use the CanInvokeMethod method.

Siebel CRM does the following work at run time:

  1. 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. For more information, see Adding a Responsibility to a Task UI.
  2. If Siebel CRM allows the user 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.
  3. If any of the following situations exist, then the task controller creates an error:
    • The task requires a business component that is not the same as the context business component.
    • The task is not activated.
  4. If Siebel CRM does not encounter an error, then it runs the task UI and opens the task pane.

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

  • Calling a task UI from a script requires UI context, meaning that Siebel CRM can reference a record in an applet. You must not configure Siebel CRM to 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 the Applet_Load event.
  • A script can pass only the name of the task UI. It cannot pass any other parameters.
  • You can use a script only to start a task UI. You cannot use a script to interact with a task in any other way.

For more information, see About Event Handling.

Example of a Client Script

In this example, the browser script locates the Create a Contact task UI, and 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 of a Server Script

In this example, the server script opens the Create a Contact task UI:

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 © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.