Monday, October 27, 2008

Create Personal SharePoint Views depending on an InfoPath field using [Me]

This article is a continue on the previous article "HOW TO Populate a List with the SharePoint Users"
Download

To download both articles, please click on the following link:

HOW_TO_Populate_a_List_with_the_SharePoint_Users.pdf

Problem

When publishing the previous form to SharePoint, and you promote the field Assign To, you will notice the newly created column is of type: Single line of Text.

clip_image001clip_image003

Figure 3: View of columns.

When you want to filter this view, using [Me], you will receive an error

clip_image005

Figure 4: Edit View page, Set Filter.

The error you receive is: The value is not a valid text string

clip_image007

Figure 5: Error Message.


Solution

In general, we need to add a new column and create a SharePoint Workflow with the SharePoint Workflow Designer

  1. Add a new column to the View

- Open the Form Library Settings page

- Click on Create Column in the Columns Section

- Enter Assign To User as Column name

- Select Person or Group as the type of the column

- Click on the Ok button

  1. Create Workflow

- Open the SharePoint Designer

- Create a new workflow (Menu File ->New -> Workflow)

- Set the workflow name: SetAssignToUserField

- Select the SharePoint list where the workflow should be attached to

- Select Automatically start this workflow when a new item is created checkbox

- Select Automatically start this workflow when a new item is changed checkbox

clip_image009

Figure 5: Define Workflow, step 1.

- Enter the Step 1 name: SetAssignToUser

- Select Set Field in Current Item under the Actions

- Click on Field and select Assign To User (the newly created column in the SharePoint View)

- Click on Value, click on the Display Data Binding Fx button

- Select Current Item as Source

- Select Assign To in the Field dropdown box

clip_image011

Figure 6: Define Workflow Lookup Dialog Box

clip_image012 Note:

Note that we just link the Assign To field (Created by InfoPath and keeps the User ID) to the Assign User To column, which is of a Person Group type.

SharePoint will execute the lookup automatically and will shows the Display Name in the view

- Click the Finish button

  1. Add the filter

- Go back to the SharePoint List

- Modify the Current View

- Select Show Items only when the following is True radio button, under the filter Section

- Select Assign User To from the Show the items when column dropdown box

- Enter in the value textbox [Me]

clip_image014

Figure 7: Filter Settings of the View

- Click on the Ok Button

10 comments:

claytoncobb said...

Nice post as it is something I already do and was about to write my own blog entry before someone pointed to this. I think it is all good except for the potential of an infinite loop in the workflow. I've reference your blog entry from my blog while adding additional concerns and info:

http://claytoncobb.wordpress.com/2009/06/29/using-me-to-filter-infopath-form-views-based-on-form-metadata/

Athena said...

Thank you very much.
All the way from Kenya

ali said...

Perfect solution, thanks a million... done and done.. took me ages to realise that it won't filter on a single line of text when I was populating it from the workflow.. cool, thanks. :)

Joshua said...

I tried this solution and got Workflow Error. (Unknown error) Can anyone please assist considering that the error does not provide much info.

Benoit said...

Brillant !!
It's save my sharepoint !

TheMapleLeaf said...

Thank-you, this was exactly what I needed!

Dileepa said...

thank u very much, it is very helpful

Dileepa said...
This comment has been removed by the author.
Zach said...

Thank you! This helped me out even 7 years later on SharePoint 2010.

2250sdod said...

wow you are a genious. what a pain to figure this out...finally got your blog...sad microsoft make us go through all this crazy workarounds to get something simple done