| serge's profileSerge Luca (Sharepoint M...PhotosBlogLists | Help |
|
May 08 Step by Step Tutorial. Creating Workflows for Windows Sharepoint Services and MOSS2007 (part 12/20). Managing several approvers/reviewers
Step by Step Tutorial. Creating Workflows for Windows Sharepoint Services and MOSS2007 (part 12/20). Managing several approvers/reviewers
By Serge LucaMVP Connected System
IntroductionThe Out-of the box approval workflow provided with MOSS allows to specify several approvers. In this post, I will illustrate how to do this. In a first time (part 1) , I will show you how to use the Replicator activity that you will need, and in a second time (part 2), you will apply this knowledge to our Sharepoint problem. If you know how the Replicator activity works you can directly go to part 2.
Part 1. Using the Replicator activityThe Replicator activity is part of the Workflow Foundation Base Activity Library, is somewhat similar to the While activity.
Recompile the project and drag & drop the custom activity into the Replicator:
In the Replicator activity, double click on the ChildInitialized event to generate an event handler :
Run the application: You can download the code here. Part 2. Using the Replicator activity in the Approval workflow
We will group these activities in a custom sequential activity.
On the OnTaskChanged activity, databind the AfterProperties and BeforeProperties to new fields:
(most of the code can be copied from Workflow1.cs)
"%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" -uf MyApprovalActivities
A first task will be created for the user "Administrator":
Congratulations !!!!
This hands-on training is the property of Redwood S.L sprl and may not be organized in class or in group without the prior written permission of Serge Luca. Should you wish to organize this hands-on training in your company or institution, please contact Serge Luca first to enter into a licence agreement. Each trainer or teacher using this hands-on training should have a licence agreement. Please ask your trainer or Serge Luca whether he or she has entered into a licence agreement with Redwood S.L sprl. The hyperlink to this hands-on training may be placed on your website for free, on the condition that the name Serge Luca is clearly mentioned in the reference. Please send us a mail containing the link to the web page our reference is used on.
May 07 Step by Step Tutorial. Creating Workflows for Windows Sharepoint Services and MOSS2007 (part 11/20). Modification Forms
Step by Step Tutorial. Creating Workflows for Windows Sharepoint Services and MOSS2007 (part 11/20). Modification Forms
By Serge LucaMVP Connected System
IntroductionModification forms allow us to reassign a workflow task to another user. 3 parts in this article:
Part 1. What are Modification FormsTo illustrate this concept, I will run a workflow provided with the downloadable version of the Sharepoint Sdk (1.3 in my case). By default, the samples are installed in the following location :
Several Infopath forms are also provided with this example and one of them which is referenced in the Modification element of the manifest is the Modification form:
The workflow is in progress; if you click on its status: You'll be redirected to this form where you have the option to reassign the task: A task has been created and assigned to serge:
..and to link it to the task Id ...and the correlation token to "taskToken1" : Recompile, and (re)install the workflow. Part 2. Understanding the EventHandlingScopeActivityThe EventHandlingScopeActivity is an activity that allows a workflow (or part of a workflow) to run while listening to events; it is a kind of (but just a kind of) ListenActivity or ParrallelActivity. Ok, I'll give you a quick tutorial on it:
These activities can be considered as part of the main flow of the workflow sequence. In the background however, the workflow can listen to events while the main flow is not completed: in the case of our Sharepoint workflow the potential event that could come up is the OnWorkflowModified event which is triggered when a task is reassigned to another owner for instance.
You'll see this :
Part 3. Using a Modification form in an existing workflow
Step 1.Add to your solution the HelloWorldSequential workflow provided with the sdk ; in its install.bat file, replace http://localhost with your site collection url, deploy it and play with it. Step 2.Add the ModSimpleModificationForm.xsn Infopath Form of ModificationSample (sdk) to the location of the HelloWorldSequential project. Step 3.Register the Modification forms in workflow.xml:
<Modification_bf35e820-5070-4e33-bc91-de30388e0b7e_FormURN> urn:schemas-microsoft-com:office:infopath:ModSampleModificationForm:-myXSD- 2006-05-17T01-22-06 </Modification_bf35e820-5070-4e33-bc91-de30388e0b7e_FormURN> <Modification_bf35e820-5070-4e33-bc91-de30388e0b7e_Name> Update task owner </Modification_bf35e820-5070-4e33-bc91-de30388e0b7e_Name>
Step 4.Run Install.bat, associate the workflow with a list and run it on a list item. If you click on the workflow status (when the workflow is "in progress", you will notice that the "update task owner" message is not visible; we need to add another functionality (next step).
Step 5.Add the EnableWorkflowModification activity just before the CreateTask activity :
You will get a rather unclear exception (if you click on the workflow completed status hyperlink): Step 6. Add a sequence activity in yhe EventhandlingScope activity and move the EnableWorkflowModification activity and the other activities that follow (disable the SendMail, LogToHistoryList and CodeActivity) into an EventHandlingScope activity (group them all in a sequence activity):
Step 7. Sending data to the modification form As we did it in one of the the tutorial, let's use xsd.exe to generate a class that will be mapped to the modification form.
private string SerializeModificationData(ModificationForm form) { using (MemoryStream stream = new MemoryStream()) { XmlSerializer serializer = new XmlSerializer(typeof (ModificationForm)); serializer.Serialize(stream, form); return Encoding.UTF8.GetString(stream.GetBuffer()); } }
ModificationForm modifForm = new ModificationForm(); modifForm.taskOwner = assignee; this._ContextData = this.SerializeModificationData(modifForm);
We still need to be able to take the modification data into account. Step 8. Sending data from the modification form
private ModificationForm DeserializeFormData(string xmlString) { using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes (xmlString))) { XmlSerializer serializer = new XmlSerializer(typeof (ModificationForm)); ModificationForm data = (ModificationForm)serializer.Deserialize (stream); return data; } }
private string newAssignee = default(string);
private void onWorkflowModified1_Invoked(object sender, ExternalDataEventArgs e) { ModificationForm modForm = this.DeserializeFormData(this._ContextData); this.newAssignee = modForm.taskOwner; }
private void updateTask1_MethodInvoking(object sender, EventArgs e) { afterProps.AssignedTo = this.newAssignee;
} step 9. Testing
Get to the Tasks list Click on the title hyperlink and modify the instructions in the form as following (here I've added "modified by admin") : Click on the Submit button. Get back to the original list, click on the workflow status ("in Progress) Update the task owner ("here to Serge) Go to the Tasks list, make sure the task owner has been modified Click on the Title hyperlink, should get the modified data in the form : Congratulations !!!
This hands-on training is the property of Redwood S.L sprl and may not be organized in class or in group without the prior written permission of Serge Luca. Should you wish to organize this hands-on training in your company or institution, please contact Serge Luca first to enter into a licence agreement. Each trainer or teacher using this hands-on training should have a licence agreement. Please ask your trainer or Serge Luca whether he or she has entered into a licence agreement with Redwood S.L sprl. The hyperlink to this hands-on training may be placed on your website for free, on the condition that the name Serge Luca is clearly mentioned in the reference. Please send us a mail containing the link to the web page our reference is used on.
|
|
|