Many to Many Relationships with SharePoint Lists

There's been much published about how to achieve a 1-many relationship using SharePoint lists such as this one (one parent to multiple children). This method works great for exhibiting master/detail-type relationships. However, I was tasked with generating a knowledge base list to which our internal IT professionals could publish content and reference for information related to various server records within our SharePoint server list for troubleshooting or informational purposes. Since any single server record could have multiple related knowledge base articles, and any knowledge base article could potentially apply to multiple server records, I needed to emulate an (automated) many-to-many relationship between the server and knowledge base list. Given the limited resources available describing how to achieve this behavior, I decided to post my solution.

My task called for a ‘Knowledge Base’ column within the server list which would contain a hyperlink to a page displaying all of the knowledge base articles pertaining to that particular server record. Here’s how I achieved such behavior:
  1. Create a multiple-value look-up column within the knowledge base list to server record values.
  2. Create a KnowledgeBase.aspx page (within SharePoint Designer) and drag/drop a knowledge base list onto the page. (See the article above for more detailed instruction).
  3. Add a data view parameter to the list called ‘ServerQS’ with value ‘ServerID’.
    • Select the list within the design view
    • Click the grey box with the ‘<’ symbol that appears to the right of the list (to access Common Data View Tasks)
    • Click ‘Parameters’
    • Click ‘New Parameter’
    • Enter ‘ServerQS’ for the parameter name
    • Select ‘Query String’ as the parameter source and enter ‘ServerID’ as the query string variable.
    • Click OK
  4. Filter the Data View by using the ServerID query string value:
    • Navigate to the Common Data View Tasks pane again.
    • Select ‘Filter’
    • Check the ‘Add XSLT Filtering’ box and click the associated ‘Edit’ button.
    • Choose ‘All’ from the ‘Select a function category:’ dropdown.
    • Select the ‘contains’ function, you should see the textbox above populate with your selection.
    • Expand the dsQueryResponse > Rows > Row tree in the left-hand navigation and select the server look-up column created earlier (I called mine ‘Network Appliance Hostname’).
    • Paste ‘$ServerQS’ as the second parameter in the contains() function within the textbox.
    • Click OK.
    • Save/publish your page.
  5. Test your reference page:
    • Create a new knowledge base article and select arbitrary server look-up values.
    • Visit your new page URL providing one of the look-up values as a query string parameter: KnowledgeBase.aspx?ServerID=TestServer.
    • Confirm your newly created knowledge base articles are displaying.
    *Note: The ‘Common Data View Tasks’ pane also provides a plethora of formatting settings for the result set such as sorting, grouping. In addition, the ‘Change Layout’ option, ‘General ‘ tab contains a toolbar option allowing users to dynamically implement their own sorting, grouping, and filtering preferences within the page.
  6. Add the knowledge base hyperlink (look-up) column to the server list:
    • Create a calculated column within the server list.
    • Provide the following formula, where ‘ServerListNameColumn’ equals the name of the column used to uniquely identify your server records (and the value provided as the ServerID query string parameter).

Posted on 1/23/2010 12:07:00 PM by sterlingt

Permalink | Comments (3) | Post RSSRSS comment feed |

Categories: MOSS 2007 | SharePoint 2007 Features | WSS 3.0 | XSLT

Tags:

Currently rated 3.0 by 10 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Related posts

Comments

July 28. 2010 11:08

SharePoint is a great solution for those who are looking for ways to build customer relationship databases. Have you guys check it out? I would love to hear your thoughts. Thanks for taking the time to post this information.

what does fml mean

May 18. 2011 01:10

Thanks for the information, helped me out a big deal. However, I have one remark: I guess you didn't consider that when you provide an id of 2, you would be selecting items that only contain a reference to id 22 too... Any clue on how to solve that?

for example, you have 2 items:
item 1 with lookup to other list items with id 2 and 5
item 2 with lookup to ids 32, 49 and 53

When the code runs, looking for items with a lookup to item 2, will also find item 2, because it contains the charachter 2...

Do you have a workaround for that? Can you solve that problem?

Greetings,

Tom

Tom

October 20. 2011 13:41

Thank you very much for your post. But it seems that the images can't display. I can't follow some steps because of the missing images. Could you please fix this problem? This post is very useful for me. Thanks.

Theodore

Add comment


 

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

May 19. 2012 11:45