Sei sulla pagina 1di 35

LAB1.CREATING SHAREPOINT DESIGNER WORKFLOWS 1.

Go to your site collection Solutions Gallery (in Site settings):

Upload the file Incidents.wsp from your Starter folder into your site collection Solution Gallery

Activate the Solution:

Once the solution is activated, a new site template ( Incidents) will be available; create a new site based on this template. Go to the Managers lists and associate the following managers to these type of incidents:

Star Sharepoint Designer 2010 and open this site. Click on the Navigation panel and select workflows:

In the workflow ribbon, select Reusable workflows.In the new dialog, name your workflow IncidentWF:

In the workflow surface, add 3 steps (click on the Step button and rename the existing step)

In the Find Manager step we will try to find the manager in charge of the incident type by doing a lookup into the Managers list; we will first create a variable to store the Manager account: click on the button Local variables in the ribbon add a local variable and name it Manager :

In the Find Manager step, add a new Action (click Action in the ribbon); select the action Set Workflow Variable in the Core actions category:

Click on the link Workflow Variable and select the variable Manager. Click on the link value, then click on the fx button to do the lookup : Select the Manager field of the Managers list; and filter on the IncidentType column :

Click on the Fx button next and filter on the IncidentType column of the current item :

Dont take the warning message into account when you click ok. Move to the second step; type start followed by enter and select Set Approval Process:

Your workflow should look like this :

Click on Approval just after start and in the next dialog, rename the task process as Litware training Incident:

Create a new local variable, name it ApprovalStatus. In the Customization panel of your Task process, click on Change the behavior of the overall task process:

Find the Step When the Task Process Completes

Store the workflow status in your ApprovalStatus variable:

Dont forget to save your workflow (Save button in the ribbon) on a regular basis. Go back to the workflow editor : you can navigate to the different workflow elements by using the navigation breadcrumb :

In the Last step (Dispatch to correct queue), test if the incident is approved and create a new list item in the appropriate list (Food Incidents, Trainer Incidents or Manual Incident).

Your step should look like this:

If the incident has been approved, we will send an e-mail to the Manager of the current manager with a reference to the new incident (in the new list). Use the Find manager activity. On the Find Manager activity, click on this user and select a workflow lookup to grab the Manager variable

Click on Add and find the Manager variable:

The output of the Find Manager action should be stored into a new variable (create it) named BigBoss :

Add a send Mail activity and send the mail to the big boss; add a workflow lookups in the message body and in the To: field

Save and publish your workflow : you will find the Publish button in the ribbon; publishing can takes a few seconds, be patient Go to the Incident CT content type definition (the Incidents list if based on this content type) and click on Workflow settings:

Click on Add a workflow and in the new window, select your workflow template ( IncidentWF); type the name Litware Incident for your workflow association (unique name..)

Go to the Incidents list, add a new Incident of type food :

Start the workflow by selecting the Workflow button in the Ribbon, select Litware Incident and start it.

If your incident type was food, the Food Manager (in this case Brianc) will have to approve the incident. Use Remote desktop and log in with Brianc account (password is pass@word1); start Outlook 2010, click on Send receive All Folder in the Send Receive Ribbon; you should get an e-mail in your inbox:

Normally when you click on the Open this task link in the e-mail message, the task form should show up, but it doesnt at least in a remote desktop (bug ?).You have to use the browser to display the task from the task list. When you click on the task, the custom task form will show up :

Click on Approve. If you go to the Incidents-Food list, you will see your new incident. In the meantime, an e-mail has been sent to Briancs boss: Keithd. Create a new Remote Desktop session with KeithD account and check his e-mail. Get back to your workflow Summary page in Sharepoint Designer and check the option Show Workflow visualization on status Page.

Publish your workflow , start the workflow and check the workflow status page: you will see the workflow rendered by Visio Services :

LAB 2.CREATING WORKF LOWS WITH VISIO 2010 1. 1. 2. Start Microsoft Visio 2010 and click on the FlowChart template category to select the Microsoft Sharepoint Workflow template. Take a look at the 2 categories of Shapes : Conditions Actions and Terminators/ Notice than we can only create sequential workflows in Visio. Drag and drop a Start and a Terminate shapes into the design surface :

Now we will query information provided by the user when the workflow starts : drag & drop a Compare Data Source Shape between the Start and the Terminate shapes, as well as 2 Log To History List shapes:

Lets connect the shapes by selecting Connector from the Ribbon:

Double click on each shape to modify the internal text as described in the picture below :

When we have a condition shape with several connectors, at least one of the connector must have a label that says yes or No; indeed, click on the Process Ribbon and select the Check Diagram menu item:

You will get several issues:

Right click on the connector and select Yes or No (only one is enough):

Save the Visio File (File_save menu) and Export it by selecting the Export menu item in the Process Ribbon :

Provide a name like MyFirstVisioWorkflow (notice the .vwi extension : Visio Workflow Interchange format):

Start Sharepoint Designer 2010 and open the http://litware web site. Click on the Workflows site object and on the Workflows Ribbon select the Import from Visio ribbon item:

Import the workflow and associate the workflow with the Announcement list; the workflow will show up in the designer:

Lets create an initiation form where we will ask the user if the information is important or not: select the Initiation Form Parameters Ribbon option in the Workflow Ribbon; add a field and name it Important; select the type Yes/No, click Next and select No for the default value.

In the Workflow Designer replace the first value with:

Replace this test with Equals and the other value with yes :

Replace this message with Important and not important:

Name the workflow step MyFirstWorkflow, save the workflow

Save the workflow (dont forget to Publish).

In the workflow Summary page, check the option Show workflow visualization on status page:

Publish the workflow. Go to the Announcements list, select an existing announcement and start MyFirstVisioWorkflow, fill in the Initiation form (Check important), and check the workflow history (in the beta 2, the workflow visualization may generate an exception)

Export the workflow to Visio by selecting the Export to Visio Ribbon item. Lets take a look at the .vwi file by renaming the file with a .zip extension

It is a simple container for 2 workflow files (workflow.xoml and workflow.xoml.rules) and a Visio diagram.

If you click on the workflow.xoml, the file will show up in Visual Studio 2010 Workflow Designer.

To import a vwi file from Visio 2010, create a new Sharepoint Workflow Diagram, and in the Process Ribbon, select Import :

LAB 3.CREATE A SIMPLE WORKFLOW WITH VISU AL STUDIO AND ASP.NE T FORMS 1. Create a new empty Sharepoint 2010 project; name the project VSWorkflowLab1. Select Deploy as Farm solution and the web site should be http://litware. Add a new SPI based on the Sequential workflow template, keep the default name workflow1.It is important to know that if we had chosen sandbox solution, the Sequential Workflow or State Machine Workflow would have been disabled. Lets keep the Site Workflow Option. The workflow cannot automatically start as it is the case for a workflow running on a list. In Solution Explorer, open the Elements.xml linked to the workflow file.

You will see a new Tag : AssociationCategories :

Other options are available; you will find more details here: http://msdn.microsoft.com/enus/library/aa543430(office.14).aspx. To add the Association and Initialization forms, we have to create a mapped folder: right click on the project , select Add and add a Sharepoint layouts Mapped Folder :

A new Layouts folder with a VSWorkflowLab1 subfolder to your project will be generated :

Right click on the VSWorkflowLab1 subfolder and add a new Item: WorklflowAssociation Form: keep the default name WorkflowAssociationForm1.aspx. Repeat the same procedure for a WorkflowInitiation Form and name it WorkflowInitiationForm1.aspx. Open WorkflowAssociationForm1.aspx and add a TextBox called MaxAmount in PlaceHolderMain.

Open WorkflowInitiation1.aspx and add a Textbox called Amount in PlaceHolderMain:

Edit the Elements.xml file and provide the association and initiation forms urls in the Worflow element:

Build and deploy your solution. This is a site workflow, therefore go to Site Actions-Site Settings-Workflow Settings to take a look at the Workflow Association. Click on your workflow name; click on the Next button to display your association form.

To start the workflow, go to Site Actions-Site Workflows and click on your workflow:

Lets update the workflow Association Forms GetAssociationData Method:

Lets update the workflow Initiation Forms GetInitiationData Method:

Drag & drop a LogToHistoryList activity to the workflow surface Bind the HistoryOutcome property to a new field called HistoryOutCome. Create a function that check the workflowProperties.InitiationData is less or equal to workflowProperties.AssociationData. Add an event handler to the OnWorkflowActivated activity and invoke this function from the event handler; store the return value into the HistoryOutCome field previously created. Save, deploy and test your site workflow.

LAB 4.CREATE A VISUAL STUDIO SEQUENTIAL WORKFLOW THAT CREATE TASKS 1. Create a new Sharepoint 2010 Visual Studio project from the Sequential Workflow template and name it HelloWorldSequentialv10.select a web site and a specific list to associate your workflow with. In this lab, this workflow will create a task, listen to task changes done by the user and complete the task. In the next lab, we will add and invoke association and initiation form, but also a task form that will override the default task form layout. Drag and drop a CompleteTask, CreateTask and OnTaskChanged activities to the workflow surface:

2.

Keep the default activities names. You workflow should look like this:

You will notice a warning message on most activities, if you click on the red balls, you will get more information about how to fix it. The first thing to do is to associate a new correlation token, which is a kind of cookies that group activities working together. Explaining correlation tokens is beyond the scope of this course. Select createTask1, display its properties windows set the CorrelationToken value to taskToken1 (you are free to choose any name):

Click on CorrelationToken and set the sub property OwnerActivityName to workflow1, which is the workflow class name.

Set the CorrelationToken property of the onTaskChange and completeTask to taskToken1. Go to the workflow1 code behind and add a new Guid property , task1Guid, that will provide your task with a unique number :

The TaskId property of our 3 new activities will be data bound to task1Guid : Select the TaskId property, click on the ellipsis () button and the following window will show up:

The task that we will create needs additional information like a description, the user that should execute the task, and other custom information that you might need. Sharepoint provides a the class SPWorkflowTaskProperties to wrap these informations. Select the CreateTask1 activity, select its property Taskproperties and bind it to new member that can be named TaskProperties1.

Click OK and take a look at the generated code.

In the workflow designer, click on the CreateTask1 activity and go to the code editor; set the following value of Taskproperties1 :

Open the Features Designer, check your feature scope (should be Site) and name; deploy your project. Go to your web site-Site collection features and make sure your feature is activated. Go to the list your workflow has been associated with, select a list item and click on the Workflow picture in the Ribbon :

Select the workflow in the list of workflows associated with your list :

Click on your workflow to start it and you will notice that a new column with the workflow association name has been created in your list:

If you click on the In progress status), you will see the workflow status & history:

You will notice that a task has been created : click on the task hyperlink (you can also go directly to the Tasks list) and the task dialog will show up :

The workflow is now waiting for your task to be changed; when the workflow is idle, it is automatically persisted (with its properties state) into the content database. If you click on the Edit Item menu, modify the task (this is optional), and click on the Save menu, an event will be sent to the workflow that will come back to life and will move to the next step. In our workflow, the next step will set the Task status to Complete.

LAB 5.CREATE A VISUAL STUDIO SEQUENTIAL WORKFLOW USING INFOP ATH FORMS 1. 2. Load the project from your Starter folder. Grab the Infopath forms from your starter folder and add them into your Workflow1 Sharepoint project item folder

In order to deploy these forms with our feature, set their Deployment Location property to Element File :

Open Elements.xml file and add the following attributes:

The AssociationUrl, InstanciationUrl and ModificationUrl attributes will specify the system page to invoke to load the association, instantiation and modification forms respectively. TaksListContentTypedId will provide a new task Content type for the task created by the workflow. We still have to specify the Infopath Forms to load; to do this you first need to find out each form unique Id : open your form in the Infopath Designer by right clicking on it on the file system and select Design:

In Infopath Designer 2010, go to the File-Info Menu and on the right side of the screen, select Form Template properties :

In the Form Template properties dialog, copy the ID:

And paste it in Elements.xml : (uncomment the tags generated by Visual Studio 2010)

Another requirement is to specify which class in which assembly will be in charge of loading the Infopath Forms; Microsoft provides an out of the box class that must be defined in the Feature.xml file. Open the feature in the Feature Designer, and click on the Manifest button:

When you click on the manifest link, the file feature.xml will show-up, but also another button: Edit Options; click on it :

Copy and paste the code provide in the script1.txt (in your Starter folder)

In the same file, add the following Property Key that will ensure that your Infopath forms will be registered in Sharepoint:

Potrebbero piacerti anche