Though you could now add the field returned from the SharePoint data connection to the form view, it would not mean much to users because SharePoint returns values to represent workflow status, not the status you see in the browser. The following table lists the values and what they mean.
Workflow value |
Status |
0 |
Not Started |
1 |
Failed On Start |
2 |
In Progress |
3 |
Error Occurred |
4 |
Stopped By User |
5 |
Completed |
15 |
Canceled |
Note |
To confirm a value and its associated Status, add the workflow field to the form template view, change the workflow status of a form in the form library or in InfoPath, then close and re-open it in InfoPath. The workflow value will appear in the control bound to the workflow field. |
Use the following procedure to add expression boxes to the form for each of these values, and conditionally hide each expression box based on the workflow field returned in the data connection.
- Type "Workflow Status:" where you want to show the workflow status in the view.
- Place an Expression Box control from the Controls task pane to the right of the text.
- In the Insert Expression Box dialog box, type "Not Started" with quotations, and click OK.
- Double-click the expression box, and click the Conditional Formatting button on the Display tab.
- On the Conditional Formatting dialog box,click the Add button .
- In the If this condition is true section, click the first drop-down box, and click Select a field or group.
- In the Select a field or group dialog box, change the data source to the SharePoint data connection.
- Click to expand the field list until you see the workflow status field, which is the name of the workflow, and click OK.
- In the Conditional Formatting dialog box, click the second drop-down box and select is not equal to.
- In the third drop-down box, select Type a number and enter the value of 0 (zero).
- Click the And button to add a second condition.
- Repeat steps six through eight to select the workflow status field.
- In the second drop-down box select is present.
- Check the Hide this control box and click OK three times to dismiss all dialog boxes.
Repeat the steps above, adding a new Expression Box control for each workflow status in the table. You can add and resize the expression boxes so they are next to each other or even slightly overlapping. Because only one status will be displayed at a time, they will always appear next to the "Workflow Status:" text.
Note |
Two conditions are also necessary for the other values in the table. The first condition is if the workflow status field is not equal to the workflow value corresponding to the status you entered in quotations in the expression box, then hide the control. The second condition is if the workflow status field is not present, then hide the control. These conditions are separated with an or instead of the default and when you click the And button to add a second condition. |
Once you are finished with adding the expression boxes, save and re-publish the form template to the SharePoint library with the same options as before. Once the form is republished, existing forms will contain the proper workflow status in the form.