SharePoint workflow solution quickflow series (2)-task

Source: Internet
Author: User

Task is the core of a workflow. How to easily express the logic of Task Distribution in a workflow system is one of the important criteria for measuring the availability of the workflow system.

By default, Sharepoint provides createtask, ontaskchanged, and completetask to allocate and process a task.

Every time a task is assigned, three activities must be processed, which is a little "troublesome". Therefore, quickflow integrates these three activities into one activity-task. Through a single task activity, the processing logic of the task can be implemented.

After you drag the task activity into the flowchart designer, you can find the following attributes:

User: Specifies the operator of a task. The task automatically assigns tasks to the user and sets the operation permissions for the task.

Tasktitle: Task Name

Tasktype: The ID of the task form, which corresponds to the taskx_urn configuration in workflow. xml.

Taskstep: The step to which the task belongs. This step is directly displayed in the workflowstep field in the list. workflowstep is the column automatically added to the workflow management list or document library by quickflow to record the current process step. Many customers will require that the list clearly shows the steps in which the current process is located. Here, you need to modify the view and display the workflowstep field after starting the workflow, you can modify the field name of workflowstep.

Autoreturn: If this parameter is set to true, a task that is automatically returned to the source after the task is completed can be returned to the submitter when multiple approvals are rejected, and then submitted by the submitter or automatically returned to the previous approver.

Taskoutcome: Task result. You can set a _ taskoutome field in the infopath form. The final value of this field is the value of taskoutcome.

Incomesync: Enter synchronization. When the upper-level approval is for multiple synchronization activities, do not set this attribute to true. In this way, the activity will be executed only after all the activities at the upper-level are completed.

A task also has the following events:

Initialized: Activity initialization event.

Taskcreating: Task creation event. Generally, task attributes are assigned values in this event. For example:

Private void taskdetailtaskcreating (Object sender, taskeventargs E)
{
// Set infopath form field value
E. taskproperties. extendedproperties ["someinfofield"] = "";
Task t = (task) sender;
T. User = "domain/useraccount ";
}

Competed: Activity completion event. Generally, user input data can be obtained in this event, for example:

Private void taskdetailcompleted (Object sender, eventargs E)
{
Task t = (task) sender;
String approveresult = T. taskoutcome;
String approvecomments = T. taskproperties. extendedproperties ["Comments"];
}

 

Common development problems:

1) How can I display the approval comments of the higher-level approval to lower-level approval during multi-level approval?

A: Save the approval comments to a global field in the completed event of the parent activity, and assign values to infopath in the taskcreating event of the subordinate approval task. For example:

String approval1comments; // The field used to save the superior approval comments

Private void taskdetailcompleted (Object sender, eventargs E)
{
Task t = (task) sender;
String approveresult = T. taskoutcome;
Approval1comments = "" + T. taskproperties. extendedproperties ["Comments"];
}

Private void task2_taskcreating (Object sender, taskeventargs E)
{
E. extendedproperties ["Comments"] = approval1comments;
}

2) Why can't I get the value when I directly access the task attribute?

A: To implement an activity that can be executed multiple times, the activity scheduling service of quickflow dynamically creates an activity during the activity execution, instead of executing the original activity, the activity on the designer is just a prototype. Therefore, when accessing an activity through an activity event, in addition to the event parameters, you can also convert the type of the first event parameter (Object sender, this object must be a running activity.

To allow direct access to the "prototype" activity for a Debian activity, quickflow synchronizes attributes after the activity is executed.

The taskoutcome attribute of the prototype activity.

To completely avoid attribute access problems, you can bind the attribute to be accessed to the workflow field so that it can always be accessed.

ExampleCodeDownload:

Http://files.cnblogs.com/jianyi0115/QuickExample.zip

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.