pp108 : Workflow

Workflow

Some process workflows comprise multiple, alternate workflow options and manual intervention is required to determine the suitable course of action. The Process Platform XForms can be a part of such workflows, where XForms can be used as the pages where users specify their preferences. In such XForms, the Workflow object is available directly on the XForm, which helps to control the Workflow object.

The properties and methods associated with the Workflow object define its behavior. The following XForms-related properties and methods can be accessed with the UI element to which the Workflow library is attached.

Table 1. List of Properties

Property

Description

commitTask

DEPRECATED. Use enableActionButton(actionType) and disableActionButton(actionType) instead. It denotes the Commit Task button on the task bar of an XForm that participates in workflows.The following methods are accessible from the commitTask property:

  • enable() - This method enables the Commit Task button.
  • disable() - This method disables the Commit Task button.

taskView

It denotes the view of the opened task. This contain the following methods:

  • close() - This method closes the current task view.
  • openTask(sTaskId) - This method opens the TaskId of the task in the currently opened task view.
  • setFocusOnActivityTab() - This method sets focus on the Activity Overview tab in the corresponding task view. If the opened task is not a case instance activity, then this method returns nothing.
  • setFocusOnCaseOverviewTab() - This method sets focus on the Case Overview tab in the corresponding task view. If the opened task is not a case instance activity, then this method returns nothing.

    Note: Task View raises the following events to notify focus and blur of Case Overview and Activity Overview tabs. Users can register listeners for these events to handle their business logic on focus or on blur of these tabs. These are raised only when the opened activity is a case instance activity.

    • onAfterFocusCaseOverviewTab - Raised on focus of Case Overview tab of Case Activity view in the Case Overview form.
    • onAfterBlurCaseOverviewTab - Raised on blur of Case Overview tab of Case Activity view in the Case Overview form.
    • onAfterFocusActivityTab - Raised on focus of Activity Overview tab of Case Activity view in the XForm participating in the workflow.
    • onAfterBlurActivityTab - Raised on blur of Activity Overview tab of Case Activity view in the XForm participating in the workflow.

      Sample Code:

      //Add the below line in InitDone Event Handler of XForm application.addListener("onAfterFocusCaseOverviewTab", focus_CaseOverviewTab); //Add the below line in OnBeforeClose event handler of XForm application.removeListener("onAfterFocusCaseOverviewTab", focus_CaseOverviewTab); //The On Focus of Case Overview Tab handler function function focus_CaseOverviewTab(eventObject) { //Your logic } 
Table 2. List of Methods

Method

Description

claimTask()

This method claims the task.

completeTask()

This method completes the task for which an XForm is a part of the workflow.

disableActionButton(actionType)

This method disables the action button for the specified action type. The possible values of the actionType are:

  • COMPLETE
  • START
  • PAUSE
  • RESUME
  • SKIP
  • SUSPEND
  • STOP
  • REVOKECLAIM
  • CLAIM

displayTaskButton(sActionType,bShown)

This method shows/hides the specified action type button in the task toolbar. It takes the following parameters:

  • sActionType- Possible arguments to this parameter are:
    • NAVBAR - hides the navigation buttons
    • HISTORY - hides the history button
    • PROCESS - hides the view process button
    • MEMO - hides the memo button
    • ATTACH - hides the attachment button
    • REMIND - hides the reminder button
    • ANNOTATION - hides the annotation button
    • COMPLETE - hides the complete action button
    • START - hides the start action button
    • PAUSE - hides the pause action button
    • RESUME - hides the resume action button
    • SKIP - hides the skip action button
    • SUSPEND - hides the suspend action button
    • STOP - hides the stop action button
    • REVOKECLAIM - hides the revoke claim action button
    • CLAIM - hides the claim action button
    • ASSIGN - hides the assign action button
    • FORWARD - hides the forward action button
    • DELEGATE - hides the delegate action button
    • MODIFYATTRS - hides the modify system attributes button
    • ALL - hides all the action buttons
  • bShown - accepts Boolean values, true or falseas arguments:
    • true - the action button will be shown
    • false - the action button will be hidden

enableActionButton(actionType)

This method enables the action button for the specified action type. The possible values of the actionType are:

  • COMPLETE
  • START
  • PAUSE
  • RESUME
  • SKIP
  • SUSPEND
  • STOP
  • REVOKECLAIM
  • CLAIM

getAssignee()

This method returns the display name of the user to whom the task is assigned. If the task is unassigned, this method returns an empty string.

getAssigneeDN()

This method returns the DN of the user to whom the task is assigned. If the task is unassigned, this method returns an empty string.

getActivityFormId()

This method returns the ID of Activity form; both in Case Activity View and BPM Activity View.

getActivityName()

This method returns the name of the Activity. This is same as the subject/description that is entered by the user in the BPM/Case Modeler for an activity.

getCaseActivityId()

This method returns the Activity ID of the current case activity. Returns null if the current activity is not a case activity.

getCaseInstanceId()

This method returns the Case Instance ID if the task is processed directly from a Case Model or if the root source is a Case Model. It also
returns the Case Instance ID when triggered from the Case Overview page. In other scenarios, it returns null.

getCaseOverviewFormId()

This method returns the ID of the Case Overview Form. It returns null if the case overview is not loaded. This may occur as the Case Overview Form is loaded only when the Case Overview Form tab is clicked.

getDeliveryDate()

This method returns the delivery date.

getMessageId()

Ths method returns the message ID.

getMessageStatus()

This method returns the message status.

getProcessInstanceId()

This method returns ID of the BPM instance or Case instance to which the Task belongs. Returns null if it is not a BPM or Case task.

getRequestTaskMessage()

This method returns the requested task message.

getSubject()

This method returns the subject.

getTaskInstanceId()

This method returns the Task ID of the current task.

getTaskOutputData()

This method returns the XML doc of the current data in the task form.

getUserOrganization()

This method returns the user organization.

hideTaskToolbar()

This method hides the Task Toolbar.

isActionPossible(actionType)

This method returns a Boolean value. If an action type can be performed, the value returned is 'true', else 'false'. Possible values of actionType are:

  • COMPLETE
  • START
  • PAUSE
  • RESUME
  • SKIP
  • SUSPEND
  • STOP
  • REVOKECLAIM
  • CLAIM

isCaseActivity()

This method returns a Boolean value. If the current activity is from a case, then the value returned is 'true' else 'false'.

isCaseInstanceView()

This method returns true if the current window displays the Case Instance view. Returns false if it is not a Case Instance view.

isTaskReadOnly()

This method returns true if the task is read-only task. Returns false if it is not a read-only task.

pauseTask()

This method pauses the task that is being executed.

planActivities(sPlanActivitiesXML)

This method takes a list of case activities to be planned while completing the current task. This method can be used in conjunction with the methods Workflow.showNoFollowupsPage() to automatically include a set of activities to be planned while completing. This abstracts case knowledge worker from choosing the required activities while completing.
The value of sPlanActivitiesXML should be in the following format:

<planactivities>
    <activity id="{2A0C054BE0FB4DB4B031601EA31853YF}"
        name="DiscussProblems" state="">
        <activityinstanceid>PARAMETER</activityinstanceid>
        <activity id="" name="" type="" xmlns="http://schemas.cordys.com/casemanagement/1.0"/>
    </activity>
</planactivities>


If you want to change or modify attributes like Target Type, Target, Assignee, or Due date, then you must provide the parameters as shown below:
For more information, check the HumanInteraction and PlanActivities APIs.

<planactivities xmlns="http://schemas.cordys.com/casemanagement/execution/1.0">
    <activity id="" name="">
        <activityinstanceid>PARAMETER</activityinstanceid>
        <case:activity id="" name="" type="HUMANTASK" xmlns:case=" http://schemas.cordys.com/casemanagement/1.0">
            <HumanInteraction xmlns=" http://schemas.cordys.com/notification/workflow/1.0 ">
                <HumanTaskModelId>PARAMETER</HumanTaskModelId>
                <InboxModelId>PARAMETER</InboxModelId>
                <Subject>Chauffeur</Subject>
                <Priority>3</Priority>
                <SendTo>
                    <ExecutionPolicy>
                        <Entry>
                            <Principal type="role"> cn=Mobility Case Handler, cn=Process Platform SINAS II Mobility, cn=cordys, cn=sostest, o=vanenburg.com </Principal>
                            <Privilege>changeduedate</Privilege>
                            <Privilege>execute</Privilege>
                            <Privilege>view</Privilege>
                        </Entry>
                        <Entry>
                            <Principal type="role"> cn=Mobility Case Reader, cn=Process Platform SINAS II Mobility, cn=cordys, cn=sostest, o=vanenburg.com </Principal>
                            <Privilege>view</Privilege>
                        </Entry>
                    </ExecutionPolicy>
                    <Target type="worklist">
                        <Assignee dynamic="false"> 54093d5f-5dfc-44d6-8189-32833246d5b3 </Assignee>
                    </Target>
                    <AssignToUser type="ASSIGN"> cn=sosadmin,cn=organizational users, o=SOS,cn=cordys,cn=sostest, o=vanenburg.com </AssignToUser>
                </SendTo>
                <DueDate dynamic="false" isDuration="true"> P0Y0M0DT2H0M0S</DueDate>
            </HumanInteraction>
        </case:activity>
    </activity>
</planactivities>

planIntermediateFollowups( sPlanActivitiesXML)

This method takes a list of intermediate follow ups to be planned from the current task. This API will render the current task in Suspended mode.
The value of sPlanActivitiesXML should be in the following format:

<planactivities xmlns="http://schemas.cordys.com/casemanagement/execution/1.0">
    <activity id="00215A62-2A6E-11E1-E42B-1CDD6C323700" name="DiscussProblems"/>
</planactivities>


If you want to change or modify attributes like Target Type, Target, Assignee, or Due date, then you must provide the parameters as shown below:
For more information, refer to HumanInteraction and PlanIntermediateActivities APIs.

<planactivities xmlns="http://schemas.cordys.com/casemanagement/execution/1.0">
    <activity id=" 00215A62-2A6E-11E1-E42B-1CDD6C323700 " name="DiscussProblems">
        <case:activity id="00215A62-2A6E-11E1-E42B-1CDD6C323700"
            name="DiscussProblems" type="HUMANTASK" xmlns=""
            xmlns:case="http://schemas.cordys.com/casemanagement/1.0"
            xmlns:ns1="http://schemas.cordys.com/1.0/xforms/processapi" xmlns:sm="http://www.w3.org/2005/07/scxml">
            <HumanInteraction xmlns="http://schemas.cordys.com/notification/workflow/1.0">
                <HumanTaskModelId> 00215A62-2A6E-11E1-E42B-1CDD6C337700 </HumanTaskModelId>
                <Subject>DiscussProblems</Subject>
                <Priority>3</Priority>
                <SendTo>
                    <Target type="worklist">
                        <Assignee dynamic="false"> 54093d5f-5dfc-44d6-8189-32833246d5b3 </Assignee>
                    </Target>
                    <ExecutionPolicy>
                        <Entry>
                            <Principal type="role">cn=Mobility Case Handler, cn=Process Platform SINAS II Mobility, cn=cordys, cn=sostest,o=vanenburg.com </Principal>
                            <Privilege>changeduedate</Privilege>
                            <Privilege>execute</Privilege>
                            <Privilege>view</Privilege>
                        </Entry>
                        <Entry>
                            <Principal type="role">cn=Mobility Case Reader, cn=Process Platform SINAS II Mobility, cn=cordys, cn=sostest,o=vanenburg.com </Principal>
                            <Privilege>view</Privilege>
                        </Entry>
                    </ExecutionPolicy>
                    <AssignToUser type="ASSIGN"/>
                </SendTo>
                <DueDate dynamic="false" isDuration="true">P0Y0M0DT2H0M0S</DueDate>
            </HumanInteraction>
            <case:messages>
                <case:input>
                    <case:message
                        name="DiscussProblems_DeliveryModel_IP" ns="http://schemas.cordys.com/1.0/xforms/processapi"/>
                </case:input>
                <case:output>
                    <case:message
                        name="DiscussProblems_DeliveryModel_OP" ns="http://schemas.cordys.com/1.0/xforms/processapi"/>
                </case:output>
            </case:messages>
            <case:associatedevents/>
            <case:escalation/>
        </case:activity>
    </activity>
</planactivities>

Note: This API triggers the identified intermediate activity and suspends the current task. However, this API will not update the current view. If you want to update the current view, then you must call the workflow.refresh() explicitly.

planFreeFollowups(planFreeFollowupsArray)

This method will take planFreeFollowupsArray parameter as input. planFreeFollowupsArray is used to handle planning of follow ups of different case levels (cases and its sub-cases). Each array element should hold planActivites xml with the caseinstanceid set as attribute in root element as shown below:

<planactivities caseinstanceid="00215A62-2A6E-11E1-E573-4891FD9F5702" xmlns="http://schemas.cordys.com/casemanagement/execution/1.0">
    <activity id="002 15A62-2A6E-11E1-E42B-1CDD6C303700" name="InformClient"/>
</planactivities>


If you want to change or modify attributes like Target Type, Target, Assignee, or Due date, then you must provide the parameters as shown below:
For more information, refer to HumanInteraction and PlanActivities.

<planactivities caseinstanceid="00215A62-2A6E-11E1-E573-4891FD9F5702" xmlns="http://schemas.cordys.com/casemanagement/execution/1.0">
    <activity id="002 15A62-2A6E-11E1-E42B-1CDD6C303700" name="InformClient">
        <activityinstanceid> 00215A62-2A6E-11E1-E573-4591FD9F5702 </activityinstanceid>
        <case:activity id="00215A62-2A6E-11E1-E42B-1CDD6C303700"
            name="InformClient" type="HUMANTASK" xmlns=""
            xmlns:case="http://schemas.cordys.com/casemanagement/1.0"
            xmlns:ns1="http://schemas.cordys.com/1.0/xforms/processapi" xmlns:sm="http://www.w3.org/2005/07/scxml">
            <HumanInteraction xmlns="http://schemas.cordys.com/notification/workflow/1.0">
                <HumanTaskModelId>00215A62-2A6E-11E1-E42B-1CDD6C337700</HumanTaskModelId>
                <Subject>InformClient</Subject>
                <Priority>3</Priority>
                <SendTo>
                    <ExecutionPolicy>
                        <Entry>
                            <Principal type="role">cn=Mobility Case Handler, cn=Process Platform SINAS II Mobility, cn=cordys, cn=sostest,o=vanenburg.com </Principal>
                            <Privilege>changeduedate</Privilege>
                            <Privilege>execute</Privilege>
                            <Privilege>view</Privilege>
                        </Entry>
                    </ExecutionPolicy>
                    <Target type="worklist">
                        <Assignee dynamic="false"> 54093d5f-5dfc-44d6-8189-32833246d5b3 </Assignee>
                    </Target>
                    <AssignToUser type="ASSIGN">cn=sosadmin,cn=organizational users, o=SOS, cn=cordys,cn=sostest,o=vanenburg.com </AssignToUser>
                </SendTo>
                <DueDate dynamic="false" isDuration="true">P0Y0M0DT2H0M0S</DueDate>
            </HumanInteraction>
            <case:messages>
                <case:input>
                    <case:message name="InformClient_DeliveryModel_IP" ns="http://schemas.cordys.com/1.0/xforms/processapi"/>
                </case:input>
                <case:output>
                    <case:message name="InformClient_DeliveryModel_OP" ns="http://schemas.cordys.com/1.0/xforms/processapi"/>
                </case:output>
            </case:messages>
            <case:associatedevents/>
            <case:escalation/>
        </case:activity>
    </activity>
</planactivities>

planEvent(sEventName)

This method accepts the event name to be planned while completing the current task. It can be used in conjunction with the Workflow.showNoFollowupsPage() method to automatically plan an event while completing. This abstracts case knowledge worker from choosing the event to be raised, if there are any applicable for this activity. The parameter sEventName is the name of the event. To know the list of available events on this activity, use the GetBusinessEvents API.

raiseEventOnCaseActivity(sCaseInstanceId, sActivityId, sEventName)

This method raises the event sEventName, in the context of case instance id - sCaseInstanceId and activity instance id - sActivityId.

refresh()

This method does a refresh of the entire task view window; it refreshes the following tabs of the task view -

  • Task Tool bar
  • Status Info tab
  • Memos tab
  • Tags tab
  • Attachments tab
  • Related Activities tab
  • Followups tab
  • Events tab
  • Fires events to refresh Case Overview and Activity Overview tabs. (These tabs are dynamic; they render the XForm that is created by the user in BPM/Case Model).

    Note: Task View window raises the following events when refresh is:

    • called through the refresh API,
    • implicitly called when any task state action is performed on the task,
    • implicitly called by the framework.
      These events can be used to handle refresh of the form of the task or the form of Case Overview in case of case instance view).
    • onAfterWorkflowRefresh - This event is raised whenever refresh is done on the task view.
      Sample Code:

      //Add the following line in InitDone event handler of the XForm application.addListener("onAfterWorkflowRefresh", onTaskRefresh); //Add the following line in OnBeforeClose event handler of the XForm application.removeListener("onAfterWorkflowRefresh", onTaskRefresh); //Event Handler for task view window refresh function onTaskRefresh(eventObject) { //Your code goes here } 

refreshView(<tab>)

This method refreshes the specified tabs of the current Task or current Case related activities in the Inbox and updates the data in those tabs. It accepts the following attributes as arguments:

  • FOLLOWUPS - refreshes the Followups tab in the current Case Instance or the current Case Activity views
  • RELATEDACTIVITIES - refreshes the Related Activities tab in current Case Instance and current Case Activity views
  • ATTACHMENTS - refreshes the Attachments tab in current Task, Case Instance, or Case Activity views
  • MEMOS - refreshes the Memos tab in current Task or current Case Activity views
  • TAGS - refreshes Tags tab in current Task or the currents Case Activity views

resumeTask()

This method resumes the task that is stopped.

revokeTask()

This method revokes the task.

showTaskToolbar()

This method makes the Task Toolbar visible.

showNoFollowupsPage()

This method will not show the Trigger Followups page while completing the Case Activity. This can be called before commiting a task, that is, onBeforeCommit action. For more information on all the available validations of task actions, refer to Validations on Task Actions

skipTask()

This method skips the task.

startTask()

This method starts executing the task.

stopTask()

This method stops the task completely.

suspendTask()

This method suspends the task.

addButtonToTasktoolbar(title,id,functionhandler,image,accesskey)

Adds a custom button to the task toolbar. Returns the button object reference.
It takes the following arguments:

  • title - Refers to the string that is used as a tooltip for the custom button
  • id - Refers to the unique ID of the custom button
  • functionhandler - Refers to the custom function handler name for the button. This function is be invoked on click of the custom button.
  • image - Refers to the URL of the image to be used as the image of the custom button
  • accesskey - Refers to the character that denotes the access key for the custom button
    You may use this method as follows :
    // Adding a button in form InitDone function Form_InitDone(eventObject) { var buttonObject = Workflow.addButtonToTasktoolbar("Demo","DemoId",CustomfunctionHandler," /cordys/wcp/theme/default/icon/feedback/question.png","c"); } // Custom function handler on button click function CustomfunctionHandler() { alert("Event Handler called"); }