1) requirement Overview
Add a View to the workflow list to display the processes/documents that the current user has approved (participated in)
2) Solutions
Add the WorkflowApprovers column of the multi-user type to the list. During the process running, add all task participants to this column, create a view, and use WorkflowApprovers to filter.
Obviously, this is a general function, and any task of any process requires this processing logic. In QuickFlow, the general process logic can be implemented by implementing WorkflowEventReceiver,
Note: This WorkflowEventReceiver is the WorkflowEventReceiver of QuickFlow, rather than the internal one of MOSS.
For WorkflowEventReceiver, refer to this article: http://www.cnblogs.com/jianyi0115/archive/2009/09/15/1567324.html
3) Implementation of WorkflowEventReceiver
CreateStrong SignatureClass Library, reference QuickFlow. dll, add a class, the Code is as follows:
Public class ApproversWorkflowEventReceiver: QuickFlow. eventBus. workflowEventReceiver {const string Field_Name = "WorkflowApprovers "; const string Field_Xml = @ "<Field Type = 'usermul' DisplayName = 'workflowapprovers' List = 'userinfo' Required = 'false' ShowField = 'imnname' UserSelectionMode = '{leonly 'UserSelectionScope = '0' Mult = 'true' Sortable = 'false' StaticName = 'workflowapprovers' Name = 'workflowa Pprovers '/> "; public override void OnTaskCompleted (QuickFlow. eventBus. workflowEventProperties p) {var taskUserAccount = p. taskProperties. assignedTo; if (String. isNullOrEmpty (taskUserAccount) return; if (p. workflowProperties. list. fields. containsField (Field_Name) = false) {// throw new Exception ("workflow list must have a multi-user field named Approvers"); p. workflowProperties. list. fields. addFi EldAsXml (Field_Xml);} var approvalUser = p. workflowProperties. web. ensureUser (taskUserAccount); // approvalUser = p. taskProperties. extendedProperties [WorkflowConstants. taskUserIdentityPropertyName] SPFieldUserValueCollection users = p. workflowProperties. item [Field_Name] as SPFieldUserValueCollection; if (users = null) {users = new SPFieldUserValueCollection ();} else {foreach (SPFieldUserValue u In users) // The user already exists. You do not need to add {if (approvalUser. ID = u. lookupId) return ;}} users. add (new SPFieldUserValue (p. workflowProperties. web, approvalUser. ID, approvalUser. name); var root = ActivityUtil. getRootActivity (p. activity) as FlowchartWorkflow; if (root! = Null) {root. DataFields [Field_Name] = users; root. DataFields. Update (); // force Update }}}
Download complete sample code
4) Configuration
Step 1:Deploy the class library to GAC, modify global. config, and add the Event Configuration:
<GlobalConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <EventReceivers> <Receiver Enabled="true" Name="ApproversWorkflowEventReceiver" Type="ProjectName1.ApproversWorkflowEventReceiver,ProjectName1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ec1e0fe6e1745628" /> </EventReceivers></GlobalConfiguration>
Step 2:Add WorkflowApprovers to the list. After adding a field, you can change WorkflowApprovers to another display name as needed.
Step 3:Create a view-my approved documents and set the filter condition to WorkflowApprovers = [myself]
5) postscript
The latest version of QuickFlow (Build120325 and later) has integrated ApproversWorkflowEventReceiver. You can directly modify global. config without having to develop WorkflowEventReceiver by yourself:
<EventReceivers> <Receiver Enabled="true" Name="ApproversWorkflowEventReceiver" Type="QuickFlow.EventBus.ApproversWorkflowEventReceiver,QuickFlow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ec1e0fe6e1745628" /></EventReceivers>