Skip to main content

Posts

Authentication with SharePoint Online and the Client Side Object Model

I was searched on Remote Authentication in SharePoint Using the Client Object Model and I found a good article on MSDN Blog With the Office 365 Beta opening not long ago people are starting to test the waters with regards to custom development and seeing what they can do etc…   We put out the SharePoint Online developers guide here to try and assist with that: http://msdn.microsoft.com/en-us/library/hh147180.aspx However, one of the topics not addressed directly in that paper is how you can use the Client Side Object Model (CSOM) to interact with SharePoint Online.  You might want to do this if you are writing an application that wants to store or talk with data stored in SharePoint Online for example. The CSOM allows you to do this in an easy to use manner by providing a library you can use to make calls to SharePoint, however, by default the CSOM doesn’t handle SharePoint Online’s authentication system. To address this gap we have published a paper and accom...

Custom Audience Targeting SharePoint 2010

Today I will  show how to create , compile Audiences using code and as well will show how to find whether a logged in user belongs to the Audience or not 1. Creating a new audience First thing we'll do is creating a custom audience, giving it two rules, joined with an OR operator. public void CreateNewAudience() { string audienceName = "Test and temp"; //audience name string audienceDesc = "Only the test and temp users."; //audience description SPServiceContext  context = SPServiceContext.GetContext(SPContext.Current.Site); AudienceManager audManager = newAudienceManager(context); AudienceCollection audCollection = audManager.Audiences; Audience audience = null; AudienceRuleComponent audRule = null;         audience = audCollection.Create(audienceName, audienceDesc);         audience.AudienceRules = new ArrayList();//initialize the collection /* An AudienceRuleComponent exists of:   ...

Get Distincit values from SharePoint list

The GetDistinctFieldValues method can only be used for Text fields. The following code example uses the GetDistinctFieldValues method to return a two-dimensional object array representing values from the Title field of a specified list and then iterates through the array to display unique values. SPSite siteCollection = SPControl.GetContextSite(Context); SPList list = siteCollection.AllWebs["Site_Name"].Lists["List_Name"]; SPField field = list.Fields["Title"]; object[,] columnItems; uint numberValues = list.GetDistinctFieldValues(field, out columnItems); for (int i=0; i<numberValues; i++) {     string uniqValue = SPEncode.HtmlEncode(columnItems.GetValue(0, i).ToString());     Label1.Text += uniqValue + "<BR>"; }

Hide Title column in custom List Defination from ONET.xml file

We can not remove Title column, we can only hide the Title column by implement this piece of xml in your ONET.xml file (for Type "0" List). <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" ReadOnly="TRUE" Required="FALSE" Hidden="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title"> </Field> <Field ID="{82642ec8-ef9b-478f-acf9-31f7d45fbc31}" Name="LinkTitle" Hidden="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="LinkTitle"> </Field> <Field ID="{bc91a437-52e7-49e1-8c4e-4698904b2b6d}" Name="LinkTitleNoMenu" Hidden="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="LinkTitleNoMenu"> </Field>

Benefits of using SharePoint Sandbox Solution

The main benefits of using sandboxed solutions are as follows: Solutions can be added to a production SharePoint Server 2010 environment without the risk of affecting processes outside the sandbox. Site collection administrators can deploy sandboxed solutions, freeing farm administrators from this task. Scalability and flexibility are increased because sandboxes run in separate process that can be restricted by quotas, and their effect on the farm can be monitored. A solution does not have to be modified or recompiled if it is moved from a sandbox to running directly on the farm.

Publish/Upload the documents to document library from local hard drive

I am sharing function to upload your files on local hard drive to SharePoint document library. In my scenario I have a file on local hard drive and upload this to a SharePoint document library and delete the file presented on local drive. The source code is // For Publish file to library private void PublishWorkbook(string strTempLocalPath, string strLibraryURL, string strFileName)         {             SPSecurity.RunWithElevatedPrivileges(delegate()                    {                        using (SPSite siteCollection = new SPSite(SiteURL))                        {   ...

Get excel column name by a known integer number

I am sharing with you a small function that enables you to get excel column name by a known integer number. function private string GetExcelColumnName(int columnNumber) { int dividend = columnNumber; string columnName = String.Empty; int modulo; while (dividend > 0) { modulo = (dividend - 1) % 26; columnName = Convert.ToChar(65 + modulo).ToString() + columnName; dividend = (int)((dividend - modulo) / 26); } return columnName; } Way to call methods string strRange = GetExcelColumnName(5); output strRange = E