We've finally reached the end of this week's four-part Workflow Conductor use case series about an InfoPath survey, and your patience is about to be rewarded. Today, it's all about the workflow! So without further ado, make sure you have your 30-day trial copy of Workflow Conductor installed, and let's get right to it.
As you know if you've been following along this week, Widget Corp has decided to offer a survey to its customers whenever they call the company. The customer is transferred to an independent survey company at the end of their call, and the survey company representative asks the customer questions and enters the results in an InfoPath form on Widget Corp's SharePoint site. Widget Corp management wants to know immediately if there is a "bad" survey result so they can address the problem right away rather than wait for the monthly report.
In part one of our series, we set up a SharePoint site with some sample data and started building a survey form in InfoPath. In part two, we configured InfoPath form controls, including a drop-down list that connected to SharePoint, hidden text boxes, and option buttons. Part three walked you through some InfoPath settings that allow the form to be submitted to SharePoint, published the survey to a SharePoint Forms Library, and enabled the form to be filled out in a browser window.
And now, part four, the last installment in this week's Workflow Conductor use case series: building a Workflow Conductor workflow that will alert Widget Corp management about "bad" survey results.
BUILDING THE WORKFLOW
Start by launching Conductor Studio from your Customer Surveys library by clicking Settings > Create or Edit Workflows.
You might remember from part two, when we were configuring the option buttons for the InfoPath survey form, that we defined a "bad" result as a rating of "1" on any question, indicating that the customer responded "Not at all". Here's what that would look like when the survey gets submitted to SharePoint:
Whenever a new survey is submitted, the workflow needs to check each of the survey question columns (Quality, Promptness, and Personnel) to see if any have a value of "1". If any of them do, the workflow will send an e-mail to the manager of the department the survey pertains to. The department name is stored in the Contact Reason column, and is the value of the drop-down list choice that the survey rep picked as the customer's reason for calling (see part two for the drop-down list box configuration). All of this can be accomplished using three Workflow Conductor widgets: Conditional Branch, Set Workflow Variable, and Send Email.
Hopefully you are fairly familiar with dragging widgets to the Studio diagram after reading the other Workflow Conductor use cases (see the end of this post for a list), so I'll give you the whole workflow up front and then show you how to configure each widget.
Conditional Branch Widget #1
We want to send an e-mail to a department manager if a survey question has a value of "1". Click on the first Conditional Branch widget in the workflow, and then click the button in the Widget Properties pane to show the Condition Builder form. Define two conditions, as shown below: the first to make sure we have a valid department name (i.e., not "Other"), and the second to check the value of one of the three question fields (in this case, Personnel). Notice the use of Current Item Field lookups to reference the columns for the current survey. You can read more about lookups in Workflow Conductor Lookups, References, and Variables.
Make sure to click Apply to save the widget settings.
Set Workflow Variable
To determine if the department manager should get an e-mail after a survey, let's use a workflow variable. This will let the workflow check all question results first, and then decide whether to send the e-mail. The value of the variable will be changed to something indicating an e-mail should be sent only if a question has a result of "1" (one of our conditions), so drop the Set Workflow Variable widget in the True branch of the Conditional Branch widget.
Before we can set the value of a workflow variable, first we have to create one. Click the Workflow Settings tab and click Add Variable in the Workflow Variables section. Add a Boolean (True or False) workflow variable called SendEmail, as shown below. Click Save to save the variable. Notice that I set the default value of the variable to False. The workflow will change it to True for bad survey results.
Now click on the Set Workflow Variable widget in the Studio diagram to configure it. Choose the SendEmail variable you just created from the Select Variable drop-down list, and type True in the Set Value property.
Conditional Branch Widgets #2 and #3
All the work has already been done for processing the other two question columns. All you have to do is copy the first Conditional Branch widget (right-click it and choose Copy) and paste it where you want it in the workflow (right-click the Studio diagram and choose Paste). Do this twice, and then edit the conditions for each of the copies to look at the Quality and Promptness columns instead of the Personnel column (don't forget to click Apply after editing the conditions).
Copying a widget also copies everything inside it, so the Set Workflow Variable widget is also copied. It's already configured, so there's nothing to change.
It might be a good idea to change the Display Name property for each Conditional Branch widget so you can keep track of which question a widget is checking. If you look at the complete workflow above, you'll see that I tacked on the question name to each Display Name.
Conditional Branch Widget #4
The first three Conditional Branch widgets have checked the three survey questions for bad results and set a workflow variable to True if there were any. Now add a 4th Conditional Branch widget to check the value of the workflow variable to see if the department manager needs an e-mail notification. There's only one condition needed: Compare these data sources to check if the SendEmail variable Equals True:
Finally, drop a Send Email widget in the True branch of the last Conditional Branch widget, and configure it to send e-mail to the manager of the department the survey was about. We cleverly set the values of the ContactReason drop-down list box in the InfoPath form to match the names of the departments in the Departments list. We can look up the manager for the department by linking the Customer Surveys library and the Departments list using an External Lookup. Click the Lookup User button () next to the To property box in the Send Email widget properties, click the Add Lookup button () in the User Lookup dialog, and configure an External Lookup to the department Manager, as shown here:
All of the other fields in the e-mail are up to you. Here's an example of a Send Email widget configured with some sensible values and lookups to alert the manager that they need to go take a look at the completed survey and take some appropriate action. The From address of the e-mail is a lookup to the survey company rep who filled out the survey (the current item's Created By column. There is also a link directly to the survey, using an Easy Reference Item URL lookup.
DEPLOY THE WORKFLOW AND SET START OPTIONS
Once all the widgets are configured, save and deploy the workflow by going to Publish > Deploy in the Conductor Studio menu. Give your workflow a name when prompted. It will automatically be associated to your Customer Surveys library.
One of our scenario requirements was that the managers wanted immediate notification when there was a bad survey. You can always run a workflow manually, but let's support our business process by changing the workflow's Start Options in SharePoint so that the workflow will run whenever a new survey is saved to the Customer Surveys library:
- In the Customer Surveys library, go to Settings > Form Library Settings.
- In the Permissions and Management section, click the Workflow settings link.
- In the Change Workflow Settings page, click the name of the workflow you deployed.
- In the Change a Workflow page, check the box in the Start Options section to Start this workflow when a new item is created, and click OK.
RUNNING THE WORKFLOW
To test this workflow, go create surveys with and without "Not at all" results selected for any of the questions. You will see that your department manager gets an e-mail similar to the one below when any of the questions has a result of "1", and no e-mail when all of the results are "2" or "3".
This Workflow Conductor use case was packed with a ton of information about SharePoint, InfoPath, and Workflow Conductor. Here are just a few of the things I hope you took away from this four-part series:
- You can use InfoPath forms to send and receive data from SharePoint lists and libraries. For even more InfoPath-SharePoint integration, check out Using SharePoint Data in InfoPath Forms: How Does it Work?
- Conditional formatting, hidden form fields, and other InfoPath features offer a way to highly customize data entry in SharePoint without coding.
- Workflow Conductor workflow variables allow you to store workflow results for later use.
- Workflow Conductor lookups allow you to refer to fields in the current item and items in other SharePoint lists.
- The Conditional Branch widget allows your workflow to take different actions depending on specific workflow conditions.
- Use workflow Start Options to support your business process by defining when your workflow runs.
If you missed any part of this series, take a few minutes to catch up:
Part 1: Workflow Conductor Use Case: An InfoPath Survey – My First InfoPath Form
Part 2: Workflow Conductor Use Case: An InfoPath Survey – Drop-Down Lists, Hidden Fields, and Option Buttons (Oh My!)
Part 3: Workflow Conductor Use Case: An InfoPath Survey – Publish or Perish…Submitting an InfoPath Form to SharePoint
Part 4: Workflow Conductor Use Case: An InfoPath Survey – Getting Results (AKA "The Workflow")
Also be sure to check out other Workflow Conductor Use Cases and informational articles: