Showing posts with label I did not know that. Show all posts
Showing posts with label I did not know that. Show all posts

Friday, July 10, 2009

Fetch SharePoint Data Programmatically

There are different ways to fetch data in Share Point. SharePoint uses CAML to query the data. Following are the possible ways to retrieve the content
FullTextSqlQuery - search
SPListItems and for each loop - object model
List Web Service - Search from remote client
SPQuery Object - Search the list
SPSiteDataQuery - Search across the site
PortalSiteMapProvider

Monday, August 18, 2008

Feature Scope

Web (Web site)
Control
Custom Action
Custom Action Group
Hide Custom Action
List Instance
List Template
Module (File Set)
Receiver

Site (site collection)
Content Type
Content Type Binding
Control
Custom Action
Custom Action Group
Feature/Site Template Association
Field
Hide Custom Action
List Template
Module (File Set)
Workflow

WebApplication (Web application)
Control
Custom Action
Custom Action Group
Document Converter
Feature/Site Template Association
Hide Custom Action

Farm (farm)
Control
Custom Action
Custom Action Group
Feature/Site Template Association
Hide Custom Action

For more information http://msdn.microsoft.com/en-us/library/ms474383.aspx

SPSite.RootWeb.AllUsers | SiteUsers | Users - Difference

We can get list of users (SPUserCollection) based on the following objects.

SPSite.RootWeb.AllUsers
SPSite.RootWeb.SiteUsers
SPSite.RootWeb.Users

"AllUsers" - Gets the collection of users from either member of the site or or who have browsed to the site as authenticated members of a domain group in the site.

"SiteUsers - Gets the collection of all users that belong to the site collection.

"Users" - Gets the collection of user objects that are explicitly assigned permissions on the Web site.

SPPrincipal - SPUser - SPWeb.EnsureUser() - SPUtility.ResolvePrincipal()

SPUtility.ResolvePrincipal() method to fetch details about the user by passing "first, last name" or "user email id" or "user login id".

SPPrincipalInfo object is used to hold user details like, first name, last name, email id, login id with domain name.

SPPrincipalInfo userInfo = SPUtility.ResolvePrincipal(objWeb, "loginID", SPPrincipalType.All, SPPrincipalSource.All, null, false);

------------------------------------------------------------------------------------------------

SPWeb.EnsuerUser() will add ther user to site, if the user does not exist and return SPUser object. We can use SPUser object to update "SPUser" field type
Example:
SPUser objUser = objWeb.EnsureUser("domain\\loginname");
item["user"] = objUser;

-----------------------------------------------------------------------------------------------

Tuesday, August 12, 2008

SPUtility - Usefull methods

For Example

SPUtility.SendEmail() send email from WSS site.

SPUtility.GetGenericSetupPath() used to access files 12 hive folder.

SPUtility.Redirect() used to redirect to another page.

SPUtility.TrasfertoErrorPage() helps to redirect to error page

SPUtility.TransfertoSuccessPage() helps to redirect to success page.

Monday, August 4, 2008

Update Last Modified Date MetaData Property

// oSPListItem["Created"] = new DateTime(2007, 1, 1); // if you need to change created date
oSPListItem["Modified"] = System.DateTime.Now;
oSPListItem.UpdateOverwriteVersion();

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitem.systemupdate.aspx

SPListItem.SystemUpdate Method (Microsoft.SharePoint)
Updates the database with changes that are made to the list item without effecting changes in the modified time or modified by fields.
UpdateOverwriteVersion - you can change the settings without creating a new version. Update() will allow you to change the modified date too but if versioning is enabled it would also create a new version


Tuesday, July 22, 2008

SPPersistedObject - Custom SharePoint Storage

Using SPPersistedObject, you can presist objects in database. It is similar to Property Bags. And aslo it has excellent feature ie., specify at what level the object should be presisted. for example, Farm level or Web Application level etc...

Friday, July 4, 2008

An external storage API is available for WSS 3.0

Store SharePoint data in external device other than SQL Server
Follow this link to know more http://support.microsoft.com/kb/938499/

Tuesday, June 17, 2008

Master Page behaviour in MOSS and WSS

Having single master page for all the sites?

If using MOSS, you can inherit from the top level master page. If you are using WSS, the out of the box functionality is that all sites utilize their own master page. You can, however, create a site template that uses the master page you wish and create all subsequent WSS sites from your template(s).

Master Page Inheritance
Master page files can be applied on a site level, but not on a page level. So a sub site can have a different master page specified than the parent, or it can inherit the master page file settings from the parent.

Wednesday, June 4, 2008

SharePoint ProcessBatchData Method for Batch Processing

Delete List Items using Batch Process, Instead of using SharePoint API. Normally we use listItem[index].Delete(); method to delete items one by one in list. But you can use "ProcessBatchData" method to delete the list items in the form of Batch Processing.

StringBuilder sb = new StringBuilder();
sb .Append("");
foreach (SPListItem item in CurrentList.Items)
{
sb.Append("");
sb.Append("" + CurrentList.ID + "");
sb.Append("" + item.ID.ToString() + "");
sb.Append("Delete");
sb.Append("
");
}
sb.Append("
");
try
{
SPContext.Current.Site.RootWeb.ProcessBatchData(sb.ToString());
}
catch (Exception ex)
{ throw ex; // Unable to delete}

Tuesday, June 3, 2008

Visual Studio : Get Assembly Public Key Shortcut

1. In Visual Studio, select External Tools from the Tools menu.
2. In the External Tools dialog, click Add and enter Get Assembly Public Key for the
Title.
3. Fill the Command textbox by browsing to sn.exe. It is typically installed at the following
location: C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sn.exe.
4. In the Arguments textbox, type the following (case sensitive) -Tp "$(TargetPath)".
5. Enable the Use Output window checkbox.
Click OK. The new command is added to the Tools menu.