Using the createTask API
The createTask API provides a generic mechanism for creating collaboration tasks from other applications. This API also allows you to specify an application that can be launched from the created task.

The only supported applications are the Web Dynpro applications.
The following creates a new business process and returns the business process ID:
int createTask(java.lang.String taskName,
IUser user,
java.util.Hashtable taskContext,
java.util.Hashtable appContext)
throws java.rmi.RemoteException
In the following table the parameters are explained:
Parameter |
Description |
|
taskName |
Name of the task |
|
user |
Object identifying the creator of the task |
|
taskContext |
Hashtable of names/values to put in context of new workflow |
|
|
The following are the name value pairs for creating a task: |
|
|
_wftemplatename_: |
Possible options are: ● QuickTask ● QuickTaskWithoutApproval ● GenericApplicationTask Default is QuickTask. |
|
_wfitemtype_: |
● If the template is GenericApplicationTask, which is a single step task this is specify the item type, for example, uwl.task.approval. If a single step approval is to be created, single step workitem type has to be created, for example, uwl.task.custom. This type must be specified in the UWL. ● If none specified a single step, confirmation task will be created. |
|
_wftaskassignees_: |
A comma separated string of login ids (portal login ids) of task assignees |
|
_wftaskapprovers_: |
A comma separated string of login ids (portal login ids) of task trackers |
|
_wfpriority_: |
The priority of the task: 0 – low 1 – medium 2 – high |
|
_wfdescription_: |
The description of the task. |
|
_wfduedate_: |
String representing due date of the task. Format is MM/DD/YYYY HHMM. If no due date is specified task will be due a week from now |
|
_wfdueasap_: |
Y if the task is due ASAP |
|
notifyOnCompletion: |
Set to true if notification is needed after task completion of task. |
|
notifyOnUpdate: |
Set to true if notification is needed after task update. |
|
_wftaskrejectable_: |
yes if the assigne can reject a task. Default is no. |
appContext |
Hashtable of name/values identifying the launch information of an external application (optional). This is only applicable for GenericApplicationTask template. |
|
|
Returns: |
Integer workflow business process ID. |
|
Throws: |
In case of problem: java.rmi.RemoteException |
To create a standard task, add the following code to your code:
IJWFPortalService service = (IJWFPortalService) PortalRuntime.getRuntimeResources().getService(IJWFPortalService.KEY);
IWorkflow eWF = service.getWorkflowEngineJMS();
IUser creator = ...;
Hashtable taskCtxt = new Hashtable();
taskCtxt.put("_wftemplatename_,"QuickTask");
taskCtxt.put("_wfduedate_,"10/10/2006 1010");
taskCtxt.put(_wftaskassignees_,"user1");
// portal login id of the assignee
taskCtxt.put(_wftaskassignees_,"user2");
// portal login id of the trackers
int bpInstanceID = eWF.createTask("task01", creator, taskCtxt, null);
This code invokes the createTask API programmatically.
You can use the createTask API to create new single step task types from which a Web Dynpro application can be launched. In the following an ERP example is described.
ERP defines a notification item type, which defines the application to be launched when clicking on the item subject, and, if required, additional actions using standard UWL launch and action configuration. Actions can be parameterized.
Add the item type configuration to the UWL item configuration.
More information:
Configuration
DTD,
Item
Type
<ItemType name="uwl.notification.erp.fyi" connector="*"
defaultView="NotificationsView" defaultAction="testlaunchapp">
<Actions>
<Action reference="complete"/>
<Action reference="forward" />
<Action name="testlaunchapp" handler="SAPWebDynproLauncher"
referenceBundle="blank"
launchInNewWindow="yes"
launchNewWindowFeatures="width=700,height=600,resizable=yes,
scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no,
directories=no">
<Properties>
<Property name="display_order_priority" value="-1" />
<Property name="WebDynproApplication"
value="WizardApplication" />
<Property name="WebDynproDeployableObject"
value="sap.com/tc~eu~jwf~ui~wizardtask" />
<Property name="System" value="${item.mysystem}" />
<Property name="type" value="button"/>
<Property name="ignoreWorkIdParams" value="yes"/>
<Property name="appContext" value="${item.myappcontext}" />
<Property name="launchContext"
value="${item.mylaunchcontext}" />
<Property name="isnewwindow" value="1" />
</Properties>
</Action>
</Actions>
</ItemType>
ERP creates a notification calling the collaboration task API (also called Java workflow (JWF) API) passing standard parameters for example subject, target user(s), priority, deadline, description but also a UWL item type like uwl.notification.erp.fyi and the parameters needed to launch the application.
...
import com.sap.workflow.es.portal.IJWFPortalService;
import com.sap.workflow.engine.api.IWorkflow;
..
..
IJWFPortalService service = (IJWFPortalService) PortalRuntime.getRuntimeResources().getService(IJWFPortalService.KEY);
IWorkflow eWF = service.getWorkflowEngineJMS();
IUser creator = ...;
Hashtable taskCtxt = new Hashtable();
taskCtxt.put("_wfitemtype_,"uwl.notification.erp.fyi");
taskCtxt.put("_wfdescription_", "my description");
taskCtxt.put("_wfpriority_", new Integer ("0"));
taskCtxt.put("_wftaskassignees_", "ardih");
taskCtxt.put("_wfduedate_", "12/20/2005 1010"); // if the due date is not set the
workflow will assume that the task is due ASAP
HashTable appCtxt = new Hashtable();
appCtxt.put("mysystem", "SAP_LocalSystem"); // <Property name="System"
value="${item.mysystem}" />
appCtxt.put("mylaunchcontext", "uwl"); // <Property name="launchContext"
value="${item.mylaunchcontext}" />
appCtxt.put("myappcontext", "test"); // <Property name="appContext"
value="${item.myappcontext}" />
eWF.createTask("test", creator, taskCtxt, appCtxt);