Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store user-specific data in SharePoint

I have some user-specific data that I need to store in SharePoint and make accessible to the user through custom webparts. Let's say a list of favorite URLs. What would be the most straightforward way to store this information?

  • Some builtin propertybag for SPUser or similar that I'm not aware of.
  • SPList, associated through User column.
  • Custom database table, associated through SPUser ID.
  • Otherwise?

Sounds like a RTFM to me, but I'm probably asking google the wrong questions.

[Update]

We eventually stored this information in a simple list, in a fixed location, with a Person field to filter on. Perhaps the simplest solution indeed, but technically I think the marked answer below is nicer.

like image 818
Paul-Jan Avatar asked May 03 '10 07:05

Paul-Jan


People also ask

Can I create a database in SharePoint?

Overview. Access 2010 and Access Services provide a platform for you to create databases that you can use on a SharePoint site. You design and publish a web database by using Access 2010 and Access Services, and people who have accounts on the SharePoint site use the web database in a web browser.

Can we store data in SharePoint?

To update the data structure, you must rewrite application logic for storing and updating data. Information stored in the list cannot be shared easily with other add-ins. You cannot search for data in SharePoint. The amount of data that you can store in lists and the size of query result sets are limited.


2 Answers

If you want to make them reusable across the site collection for each user you can add Fields to the User Information List. You can add a feature receiver to your web parts solution that can create this column or check to see if this column exists in the User information list to be sure that the Column exists.

The User Information list is a Standard SharePoint list that SharePoint uses to store user information. To access the User Information List you can go to the Root web of the Site Collection and use the SiteUserInfoList property

E.G.

SPList userInformationlist = SPContext.Current.Site.RootWeb.SiteUserInfoList;
//Or 
SPWeb web = SPContext.Current.Site.RootWeb;
SPList userInformationlist = web.SiteUserInfoList;

To access a users List Item you can use the Users Id to get the ListItem back from the User Information List

E.G.

SPListItem currentUserItem = userInformationlist.GetItemById(web.CurrentUser.ID);

If you are using MOSS you can store this information in the User Profiles and make it available across Site Collections this does not need My Sites to be enabled. You would need to use the User Profile classes to access this.

like image 70
JC Vivian Avatar answered Oct 10 '22 21:10

JC Vivian


I would go for the properties on the user profiles. You do not want to store the information on the root web as it is not information regarding the root web. Your example with the favorite urls, each user has a "quick links" collection on their profile. An ideal place for storing urls for each user. :)

like image 43
JWL_ Avatar answered Oct 10 '22 22:10

JWL_