Wednesday, April 23, 2014

Filter Predecessor by Projects in SharePoint 2010 Task List

We created a Task List for the internal portal to assign tasks within our team members. The Predecessor field in the Task list lists downs all the values entered for the Title field. It grows when we keep adding items to the list. To overcome this problem, we decided to add a field call Project and filter the Predecessor by projects. Following section describes how to achieve this.

To add values to the Project dropdown list, create a custom list named ‘Projects’ and use that list as a lookup field. Add some projects to the list. These project names will be displayed at the Task List at the dropdown list.

1. Next create a Task List named ‘Project Tasks’.

2. Create a Lookup column named ‘Project’, to list down available projects with the following information.

clip_image002

3. Next we are going to edit the form with InfoPath to do the customization. Click on the ‘Customize Form’ to open the form.

clip_image004

The form will be opened in InfoPath 2010.

clip_image006

4. Right click on Project field and select Drop-Down List Properties.

5. Select ‘Get choices from an external data source’ and click Add.

clip_image008

6. Create new data connection using the Data Connection Wizard.

7. Select Receive data option

clip_image010

8. Select the source as SharePoint library or list.

clip_image012

9. Select the ‘Projects’ list.

clip_image014

10. Select ID and Title fields.

clip_image016

11. Don’t select Store a copy of the data in the form template option.

clip_image018

12. Enter the data connection name as ‘Projects1’ and click Finish.

clip_image020

We have created the data connection for the Projects dropdown list.

13. Set the Value and the Display name properties as ID and Title respectively.

clip_image022

Next we need to do the same steps for the Predecessor field as well.

14. Right click on the Predecessor field and select Multiple-Selection List Box Properties and create a new Data Connection.

15. From ‘SharePoint library or list’ select ‘Project Tasks’, select ‘Title’, ‘ID’, and ‘Project’ column.

16. Don’t check the box for making a copy of the data in the form Template.

17. Do not check the box that asks for automatically retrieving data when the form is opened. Save the external data source as ‘Project Tasks1′

18. Set ID and Title for the Value and the Display name respectively.

We are almost done. Next we need to do the filtering for the Predecessor with the following steps.

19. Click on the xPath button at the properties dialog next to the ‘Entries’.

clip_image024

20. Click on the ‘Filter Data’ button and Click Add.

clip_image026

21. At the first column, pick ‘Select a field or group’.

clip_image028

22. A window pops up .Select the ‘Main’ data source, click on ‘dataFields’ and select ‘Project’

clip_image030

23. In the second column, choose ‘equals to’.

24. At the third column, choose ‘select a field or group’. Again a window pops up. Select the ‘Project Tasks1’ datasource, click on ‘dataFields’ and select ‘Project’. Click OK.

clip_image032

Your filter data will look like Project = Project. Next we are going to add some rules to the Project dropdown list.

25. Select the Project column and click on ‘Add Rule’. Select ‘The Field Changes’ and select ‘Query for Data’.

clip_image034

26. Now choose the Data connection ‘Project Tasks1′ and click OK.

clip_image036

27. Again add a new rule for the Project dropdown list. This time select ‘The Field Changes’ and select ‘Set a Field’s Value’.

28. Choose field ‘Predecessor’ and leave the value empty.

clip_image038

We are done now. Quick publish the Form. You will see the following when you try to add new item.

clip_image040