Wednesday, November 27, 2013

Hide fields in NewForm, EditForm and DispForm in SharePoint 2010 using SharePoint Manager

In this post, we will discuss how we can hide a field from NewForm, EditForm and Display Form in SharePoint 2010 using SharePoint Manager Tool.

To know more about SharePoint Manager Tool, you can follow my previous article.

Also, you can check my previous posts on:

- Working with Resource file in SharePoint 2010

- Implement a breadcrumb into SharePoint 2010 website

- Deploy custom images to SharePoint2010

Read Show hide fields based on permission in SharePoint list form using Client Object Model

To do this through SharePoint Manager, Open the Tool by double-clicking on the exe file.

Then from the left-hand side, you can select the particular column name from the left side of the tool and then you can change the property ShowInDisplayForm to false, like that you can change for other fields also. Check the fig below:



Tuesday, October 8, 2013

Methods available in UserProfileService in infopath 2010

In this post we will discuss what are all the methods are available in UserProfileService.asmx web service in infopath in SharePoint 2010.

Also you can check out my previous posts on:

- SharePoint Designer 2010 Best Practices

- hide ribbon in sharepoint 2010

- Change master page programmatically SharePoint 2010

While creating a data connection, we can make the data connection by calling the Userprofileservice web service.

Sunday, October 6, 2013

SharePoint developer walkin in various locations

Here is a SharePoint developer walkin in Bangalore for various location.

Experience: 3.5 - 6 years

Job Location: Bengaluru/Bangalore, Chennai, Gurgaon

Company Name: Accenture

Skills : SharePoint Developer

Sunday, September 22, 2013

Infopath form status showing installing while deployment in SharePoint 2010

In this post we will discuss how to solve when the infopath form shows status as installing in SharePoint 2010. Also you can check my previous posts on:

- Get icon for different file types in SharePoint 2010

- Create event receiver in Sandboxed solution is SharePoint

- Create an approval workflow in SharePoint Designer 2010

Sometimes when you upload an infopath form template in the central administration, it will stuck and shows installing status in the central administration. You can see this in the Central Administration -> Manage Form Templates.

Wednesday, September 4, 2013

Limitations of workflow in SharePoint 2010

Here we will discuss some of the limitations of SharePoint 2010 workflow. You can read previous posts on:

- Get icon for different file types in SharePoint 2010

- Disable default email for approval workflow in SharePoint 2010 designer

- Create list item using JavaScript object model in SharePoint 2013

1- SharePoint 2010 can have only one workflow execution host per SharePoint 2010 farm, shared between all web applications. Because workflow is not a service in SharePoint 2010.

Friday, August 30, 2013

SharePoint walkin in Capgemini for developers and senior developers

Capgemini is conduction walkin on 31st Aug 2013. Below are the job details:

Work Location - Bangalore

SharePoint Developers & Senior Developers

- SharePoint 2010, MOSS 2007

- SharePoint Designer

- Skills / knowledge on.NET Framework 3.5

Tuesday, August 20, 2013

Get icon for different file types in SharePoint 2010

In this post we will discuss how we can get icon for different file types in SharePoint 2010. Also you can check out my previous posts on:

- How to get value from people picker control in infopath in SharePoint?

- Disable default email for approval workflow in SharePoint 2010 designer

- How to make date time picker read-only in InfoPath 2010?

If you are working in custom search and your search result in returning various file types like

Saturday, August 10, 2013

How to Configure SSRS for SharePoint Integration Mode in SharePoint 2010?

Here in this article we will discuss how to Configure SSRS for SharePoint Integration Mode in sharepoint 2010? Also you can check out my previous posts on:

- Change due date for Task list in SharePoint designer 2010 workflow

- How to create a Site Definition using Visual studio 2010 in SharePoint 2010?

- Working with SharePoint 2010 search web service

SSRS has two modes.
1-Native mode:Build reports by hand and then look at them.

2-Integration mode:SharePoint Integration mode allows you to add Reporting Services content types to SharePoint, and then build and manage your reports from SharePoint.

Friday, August 9, 2013

Disable default email for approval workflow in SharePoint 2010 designer

In this post we will discuss how to disable default email notification for approval workflow in SharePoint designer 2010. Also you can check out my previous posts on:

- E-Mail Event Receivers in SharePoint 2010

- Show SharePoint list data in repeating table in infopath 2010 using SharePoint object model

- Architectural changes in SharePoint 2013

Before reading this, check out this article on Reusable Approval workflow in SharePoint designer 2010. If you will create workflow like explained in this article then by default

Monday, July 29, 2013

SharePoint 2010 designer Workflow not publishing error

If you are working in SharePoint 2010 designer workflow, you might get an issue while publishing a workflow. Sometimes if you modify the workflow and publish it, but SharePoint still shows the old details.

Before that, you can also check out my previous posts on:

- Bind drop-down list from SharePoint list in InfoPath 2010

- Copy or Move files from one folder to another folder using SharePoint 2010 object model

- Add custom web part properties to the visual web part in SharePoint 2010

Thursday, July 25, 2013

How to make date time picker read-only in InfoPath 2010?

In this post we will discuss how to make date time picker read-only in InfoPath 2010. Also you can check out my previous posts on:
- Get internal name of a field in SharePoint 2010

- Attach event receivers to SharePoint list using PowerShell

- How to get userprofile properties in SharePoint 2013 object model?

There are certain controls like Textbox, Rich Text Box can made read only by simply right click and go to the properties and then navigate to the Display tab and then select the check box Read-only . But controls like Dropdownlist, Check box, Date Picker, Date and Time Picker we can not make read-only like this.

Monday, July 15, 2013

Bind dropdownlist from SharePoint list in InfoPath 2010

In this post we will discuss how we can bind a dropdownlist from a SharePoint list in InfoPath 2010. Also check out my previous posts on:

- Read SharePoint 2010 list data using jQuery

- Add custom Submit button in InfoPath form in SharePoint 2010

- Set the Bing Maps key at the web and farm level in SharePoint 2013

Follow below steps:
Step-1:
Open InfoPath (Start -> All Programs -> Microsoft Office -> Microsoft InfoPath Designer 2010), then select Blank Form and Click on Design Form.

Step-2:
Then from Home tab go to the Controls section and add a dropdownlist to the InfoPath form.

Step-3:
From the Ribbon select Data tab and select Data Connections as shown in the figure below:

Step-4:
In the Data Connections wizard click on Add... as shown in the figure below:

Step-5:
In the next step select Create a new connection to Receive data and click on Next as shown in the figure below:

Step-6:
In the next step select SharePoint library or list and click Next as shown in the figure below:

Step-7:
In the next step give the SharePoint site details and Click on Next as shown in the fig below:

Step-8:
Then Select the list from which you want to bind the data as shown in the fig below:

Step-9:
In the next step, select the fields which you want to retrieve and sort order and click on Next as shown in the fig below:

Step-10:
Then click on Next and do not modify anything for Store a copy of the data in the form template.


Step-11:
Then give a name for the data connection and select the checkbox Automatically retrieve data when form is opened as shown in the fig below and click on Finish.

Step-12:
Now Right click on the DropDownList and Select Drop-Down list properties and optionally change the field name and Select Get Choices from an external data sources. And in the Data Source field select the data source name that we have just created. Here you can change the Display name field to what ever field you want.

Step-13:
Now you can publish the form. The data should bind from the SharePoint list as shown in the figure below:

Sunday, July 14, 2013

InfoPath cannot open the selected form because of an error in the form's code. Policy settings prevent opening Internet forms with managed code. To fix this problem, contact your system administrator

In this post we will discuss how to solve an infopath error which I got while opening infopath form in SharePoint 2010. The full error message is "InfoPath cannot open the selected form because of an error in the form's code. Policy settings prevent opening Internet forms with managed code. To fix this problem, contact your system administrator".

You can check out my previous posts on:

- Disadvantages of external lists in BCS

- PowerShell cmdlets for SharePoint 2010

- Add custom send to destination in ECB menu in SharePoint 2010

Saturday, July 13, 2013

System.Security.SecurityException Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed.

I got this error while publishing an Infopath form which has object model code in SharePoint 2010. The full error message is "System.Security.SecurityException
Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed.".

Also you can check out my previous posts on:

Friday, July 12, 2013

This session has exceeded the amount of allowable resources - infopath form error

In this post we will discuss how to solve an infopath 2010 error "this session has exceeded the amount of allowable resources".

You can also check out my previous posts on:

The amount of data that was returned by a data connection has exceeded the maximum limit that was configured by the server administrator SharePoint infopath 2010 error

In this post we will discuss how to resolve the infopath 2010 error message"
The amount of data that was returned by a data connection has exceeded the maximum limit that was configured by the server administrator.


Click OK to resume filling out the form. You may want to check your form data for errors. ".

You can also check out my previous posts on:

Friday, July 5, 2013

Could not load file or assembly 'Microsoft.Sharepoint.Sandbox' or one of its dependencies. An attempt was made to load a program with an incorrect format.

In this post we will discuss about how to solve the error message "Could not load file or assembly 'Microsoft.Sharepoint.Sandbox' or one of its dependencies. An attempt was made to load a  program with an incorrect format."

Also you can check out my previous posts on:
- Tutorial on User Profile service application in SharePoint 2013

- Attach event receivers to SharePoint list using PowerShell

- Workflow custom form changes in SharePoint 2013

Wednesday, July 3, 2013

Enable target audience in list in SharePoint 2010

In this post we will discuss how to enable target audience in SharePoint list or document library using browser in SharePoint 2010.

Also you can check out my previous posts on:

- Tutorial on User Profile service application in SharePoint 2013

- Create content type in SharePoint 2013

- Create document sets in SharePoint 2013

The steps will be same for List or document library. By default target audience is not enabled for list or document library. Follow below steps to enable target audience in list or document library:

Friday, June 7, 2013

SharePoint developer openings in Accenture

Here is an opening in SharePoint with Accenture.

Job Description:
Experience required for the Job: 3 - 6 years

This is permanent and direct payroll with Accenture only....

Client : Accenture

Thursday, May 30, 2013

The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service. For more information, contact your server administrator

Also you can check out my previous posts on:

- Backup of Site collection in SharePoint 2010

- Event Receivers in SharePoint 2010

- Create External List in SharePoint 2013

Error:
I got this error message while working in Infopath 2010. The full error message is "The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service. For more information, contact your server administrator".

Tuesday, May 28, 2013

Enable Sign in as Different User Option in SharePoint 2013

Here in this article, we will discuss the steps to enable "Sign in as Different User" Option in SharePoint 2013.

In SharePoint 2013 there is no option for "Sign in as different user" default. So we need to follow certain steps to Enable this option manually.

If you will go to the "System Account" drop-down, You won't find any option as "Sign in as Different User".

Sunday, May 26, 2013

Build browser based solution in SharePoint 2013

In this video you will see how to build browser based solution in SharePoint 2013. This video is presented by Asif Rehemani one of the popular SharePoint certified trainer and author.

Basically he will show you how to add functionality using just browser.

Example how easily you can add links into the site. Also explains about Site Contents  improvements in SharePoint 2013.

Saturday, May 25, 2013

Architectural changes in SharePoint 2013

In this post we will discuss about some Architectural changes in SharePoint 2013. Also you can check out my previous posts on:

- Create content type in SharePoint 2013

- Advantages of Apps in SharePoint 2013

- New Features of SharePoint 2013

- There are various improvements made towards database layer like advanced indexing feature implemented towards SQL Server 2008 R2 and SQL Server 2012. Also incorporate a new feature called shredded storage through which only the changed pieces are updated at the database layer. This reduces the impact caused by document updates.

Tuesday, May 21, 2013

Get list level content types using SharePoint 2010 client object model

In this post we will discuss about how to get list level content types using SharePoint 2010 client object model. Also you can check my previous posts on:

- Get all first level subsites under website in SharePoint 2010

- Tutorial on Microsoft Office 365

- Call jQuery to SharePoint page using Custom Action

To work with SharePoint 2010 client object model, we need to give reference to the below dlls:

Wednesday, May 15, 2013

Create document sets in SharePoint 2013

In this post we will discuss how to create document sets in SharePoint 2013. Also you can check Event Receivers in SharePoint 2010, Backup of Site collection in SharePoint 2010 and  Hide Ribbon from Read Access users in SharePoint 2010.

Open the site collection. Then from the top level of your site collection, select Site Settings from the Site Actions menu. The Site Settings page appears.

Under the Galleries group, select Site Content Types. The Site Content Types page appears listing all content types available within the site collection.

Saturday, May 11, 2013

Copy or Move files from one folder to another folder using SharePoint 2010 object model

In this article we will discuss about how to copy files from one folder to another folder using SharePoint 2010 object model.

Also you can check out my previous posts on: CAML designer for SharePoint 2013, custom timer job sharepoint 2010 and SharePoint 2010 Centered Fixed Width Design.

Copy files in SharePoint:

SPWeb mySite = SPContext.Current.Web;

SPFolder myFolder = mySite.GetFolder("MySourceFolder");

Tuesday, May 7, 2013

Get all first level subsites under website in SharePoint 2010

In this post we will discuss how to retrieve all first level sub sites under a site or site collection. Also you can check out my previous posts on Powershell command to install activate feature SharePoint 2010, SharePoint 2010 Interview Questions and Answers and Reindex feature in list and document library in SharePoint 2013.

We have to use the Webs property of SPWeb class to get the first level subsites of a specific website. Below is the full SharePoint 2010 object model code:

Friday, May 3, 2013

Retrieve all site collections inside web application in SharePoint

In this post we will discuss how to retrieve all site collections presented inside a web application.

Also you can check out my previous posts on Redirect user based on browser language in SharePoint 2010, Change page layout programmatically SharePoint 2010 and Get user profile using SharePoint 2013 object model.

Here we will use SharePoint 2010 server object model to retrieve site collection list.

Tuesday, April 30, 2013

Retrieve all web site title and list title in current site collection in SharePoint

In this post we will discuss how to retrieve all web site title and list title of the current site collection using SharePoint 2010 object model.

Also you can check out my previous posts on Create custom page layout in SharePoint 2013, Fix width of master page in SharePoint 2010 and Create custom permission level in SharePoint 2013.

Below is the full code:

SPSite siteCollection = SPContext.Current.Site;

SPWebCollection collWebsite = siteCollection.AllWebs;

Thursday, April 18, 2013

Linked Data Sources in SharePoint 2010

In this post we will discuss what is linked data sources in SharePoint 2010. Also you can check my previous posts on Hide Ribbon from Read Access users in SharePoint 2010, Backup of Site collection in SharePoint 2010 and SPWeb.GetSubwebsForCurrentUser Method SharePoint 2010.

- A linked data source allows the designer to combine the data from multiple data sources into a single set of data. The data sources being linked need not be of the same type.

Wednesday, April 17, 2013

Create new site group in SharePoint 2013

In this post we will discuss how to create a site group in SharePoint 2013. Also you can see my previous post on Cross site publishing in SharePoint 2013, Hardware and Software requirement for SharePoint 2013 and New master pages in SharePoint 2013.

Follow below steps to create new site SharePoint group:

Step-1:
From the Top level of site collection go to Site Actions -> Site Settings.

Tuesday, April 16, 2013

Add user to group in SharePoint 2013

In this post we will discuss about how to add user to a SharePoint group in SharePoint 2013. Also you can check out my previous posts on Hover panel in SharePoint 2013 search, Reindex feature in List and document library in SharePoint 2013 and What's new in workflow in SharePoint server 2013.

Follow below steps to Add user to SharePoint group:

Step-1:
From the Top level of site collection go to Site Actions -> Site Settings.

Create custom permission level in SharePoint 2013

In this post we will discuss about how to create a custom permission level in SharePoint 2013. You can also check out eDiscovery in SharePoint 2013, HTML field security option in SharePoint 2013 and OAuth in SharePoint 2013.

Follow below steps to create custom permission level:

Step-1:
From the Top level of site collection go to Site Actions -> Site Settings.

Sunday, April 14, 2013

SharePoint 2013 out of box templates

In this post we will discuss about various out of box templates in SharePoint 2013. Below are out of box templates category wise:

1- Collaboration Templates:
- Team Site: This template is useful for a team that needs to share general content.

- Blog: This template is useful when you want to empower a user or group of users to publish information related to a topic on an intranet or employee portal.

- Project Site: This template is used for a project team that requires a common location for the storage of project documentation, milestones, and assignments.

Saturday, April 6, 2013

Benefits of SharePoint 2013

In this video tutorial, it explains about various benefits of SharePoint 2013. The video is from Gig Werks company.

Also check out various articles on Create visual webpart in SharePoint 2013, Get user profile properties in SharePoint 2013 using object model,  New in mobile devices in SharePoint 2013.

Also check out various new features of SharePoint 2013.

Saturday, March 30, 2013

Create content type in SharePoint 2010

In this post we will discuss how to create a content type in SharePoint 2010 using browser. You can check a good article on What is Content type in SharePoint 2010. You can also check out how to create content type using visual studio 2010 in SharePoint 2010.

To create a content type follow the below steps:

Steps-1:
Open SharePoint 2010 site then click on Site Actions and then Site Settings.

Friday, March 29, 2013

Enable Disable attachment column in SharePoint 2010 list

In this post we will discuss how to enable or disable the attachment column in SharePoint 2010 list.

You can also check my previous posts on Create External List in SharePoint 2013, Add items to SharePoint list using PowerShell and LINQ to SharePoint 2010.

To enable or disable attachment column follow below steps:

Step-1:
Open the SharePoint site, Navigate to the particular SharePoint list.

Saturday, March 23, 2013

Create custom list in SharePoint 2013

In this post we will discuss how to create a custom list in SharePoint 2013. Also you can check my previous posts on how to create a web application in SharePoint 2013 and how to create a site collection in SharePoint 2013.

You can also check Hover panel in SharePoint 2013 search, App parts in SharePoint 2013 and Different Authentication mechanism in SharePoint 2010.

Follow below steps to create a list in SharePoint 2013:

Thursday, March 21, 2013

sharepoint 2010 new web application this control is currently disabled error

Sometimes the new button is in disable state in the central administration while trying to create a web application in SharePoint 2010.

Also you can check my previous posts on:

- New features in SharePoint 2013

- Create content type in SharePoint 2013

- Limitations of Sandboxed Solutions in SharePoint 2010

There are several reasons for that like:

You should be logged in with one Admin account.

Apart from that you can check some solution:

Solution-1:
Try to run Central Administration as administrator like below:

Start -> All Programs -> Microsoft SharePoint 2010 Products -> right click on SharePoint 2010
Central Administration -> click on Run as administrator

Solution-2:
You should try to run IE in Administration mode.

Right click on IE and then click on Run as Administrator.

Solution 3:
- Go to control panel
- Here click on "System and security"
- Now here under Action center click " Change user account control settings"
- Get the scroll bar to never notify.
- Click on OK.
- Restart your system.

Solution-4:
Try to login to central administration with a user account which belongs to a administration group.

Now open the browser in "run as administrator" mode.

Friday, February 22, 2013

Get SharePoint list id using SharePoint object model

In this post we will discuss about how we can get the list id of a particular SharePoint list using SharePoint 2010 object model.

Also check previous posts on My Site document libraries improvements in SharePoint 2013, Create a Survey in SharePoint 2010 and  Modify All Items view using SharePoint object model.

Below is the code that will give the list if of a SharePoint list.

Saturday, February 16, 2013

How to get userprofile properties in SharePoint 2013 object model?

In this post we will discuss about how to retrieve UserProfile properties in SharePoint 2013 using object model. You can also check some tutorials on SharePoint Server object model and Client Object Model SharePoint 2010.

Below is the code:

using Microsoft.Office.Server.Social;

using Microsoft.Office.Server.Administration;

Wednesday, February 13, 2013

Delete webpart using client object model in SharePoint 2010

In this post we will discuss about how to delete a web part using SharePoint 2010 client object model.

You can also check my previous posts on Document Sets in SharePoint 2010, Add safe controls programmatically in SharePoint 2010 and Developer Dashboard in SharePoint 2010.

Below is the code to delete the webpart using SharePoint 2010 client object model:

ClientContext ctx = new ClientContext("http://SiteURL");

Saturday, February 9, 2013

Content Search Web Part in SharePoint 2013

In this post we will discuss about the new Content search webpart which was introduced in SharePoint 2013.

You can also check my previous posts on: New microblogging features in SharePoint 2013, SharePoint 2013 workflow development tools and New master pages in SharePoint 2013.

SharePoint Server 2013 has added a new Content Search Web Part that displays content that was crawled and added to the search index.

Tuesday, February 5, 2013

SharePoint 2013 in-place holds

In SharePoint Server 2013, content that is put on hold is preserved, but users can still change it. The state of the content at the time of preservation is recorded. If a user changes the content or even deletes it, the original, preserved version is still available. Regular users see the current version of the content; compliance officers who have permissions to use the eDiscovery features of SharePoint Server 2013 can access the original, preserved version.

In-place holds in SharePoint Server 2013 offer improvements to the hold functionality in earlier versions of SharePoint Server. Improvements include the following:

Sunday, January 27, 2013

Create an approval workflow in SharePoint Designer 2010

This is a video tutorial that explains about how to create an approval workflow in SharePoint designer 2010.

You can also check SharePoint 2013 workflow development tools and Create a sequential workflow using Visual studio 2010 in SharePoint 2010 [Read here].

Thursday, January 24, 2013

Check if Item is in document set in SharePoint 2010

In this post we will discuss how to check if an item is present in a document set programmatically using SharePoint 2010 object model.

You can also check my previous posts on: WebPart custom Properties, Download CAML designer for SharePoint 2013 and What you can do with Sandboxed Solutions?

To work with document sets using SharePoint 2010 object model, we have to use

Microsoft.Office.DocumentManagement.DocumentSets namespace.

Below is the full code:

public bool IsDocumentSetItem(SPListItem itemToCheck)
{
bool documentSetItem = false;

if (itemToCheck.File != null)
{

DocumentSet documentSet = DocumentSet.GetDocumentSet(itemToCheck.File.ParentFolder);

if (null != documentSet)
{
documentSetItem = true;
}
}
return documentSetItem;
}

Tuesday, January 22, 2013

Upload file to document library using SharePoint 2010 obect model

In this article we will discuss about how to upload a file to a document library programmatically using SharePoint 2010 object model.

Here we will upload a document to the Shared Documents document library.

You can also check out my previous posts on: RunWithElevatedPrivileges in SharePoint 2010, Redirect User to Success or Error page in SharePoint and New Features of SharePoint 2013.

using (SPSite site = new SPSite("http://SiteURL"))
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;

SPFolder folder = web.Folders[site.URL + "/Shared Documents/"];

byte[] content = null;

using (FileStream filestream = new FileStream(@"C:\MyDocument.docx",System.IO.FileMode.Open))
{
content = new byte[(int) filestream.Length];

filestream.Read(content, 0, (int) filestream.Length);

filestream.Close();
}

SPFile file = folder.Files.Add("MyDocument.docx", content, true);

}
}

Wednesday, January 16, 2013

Add an attachment to List item using SharePoint object model

In this post we will discuss about how to add an attachment using SharePoint 2010 object model.

You can also check my previous posts on Get 14 hive file path by using SharePoint 2010 object model [Read here], Get URL value SharePoint hyperlink field [Check here] and How to get Absolute URL of List using SharePoint object model? [Solution here].

string listItemID = "ID of the list item";

using (SPSite site = new SPSite("http://Site URL"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["MyCustomList"];
SPListItem newItem = list.GetItemById(listItemID);

byte[] contents = null;

if (fileUpload1.PostedFile != null && fileUpload1.HasFile)
{

using (Stream fileStream = fileUpload1.PostedFile.InputStream)
{
contents = new byte[fileStream.Length];
fileStream.Read(contents, 0, (int) fileStream.Length);
fileStream.Close();
}

SPAttachmentCollection attachments = newItem.Attachments;
string fileName = Path.GetFileName(fileUpload1.PostedFile.FileName);
attachments.Add(fileName, contents);
newItem ["AttachmentName"] = fileName;
newItem.Update();

}
}
}

Here fileUpload1 is the file uploaded control. And AttachmentName is the column name in the list.

Tuesday, January 15, 2013

Create list programmatically using SharePoint object model

In this post we will discuss about how to create a SharePoint list using object model.

You can also check my previous posts on How to Create List and Add Item to that List using SharePoint 2010 client object model? [Solution here], RunWithElevatedPrivileges in SharePoint 2010 [Read here] and Different ways to check logs in SharePoint [Check here].

Below is the code to create list programmatically using SharePoint object model.

using (SPSite site = new SPSite("http://Site URL"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = null;
string listName = "MyCustomList";

// Check whether the list already exists
try
{
list = web.Lists[listName];
}
catch (Exception ex)
{
}

if (list == null)
{
Guid listId = web.Lists.Add(listName, "Our Custom List", SPListTemplateType.GenericList);
list = web.Lists[listId];
list.OnQuickLaunch = true;
list.Update();
}
}
}

The above code will create a generic list without any extra field. And it will show in Quick Launch.

You can also add custom columns like below:

list.Fields.Add("FirstName", SPFieldType.Text, true);
list.Update();

Saturday, January 12, 2013

Create and Add user to Groups in SharePoint using Object model

In this post we will discuss how to create a SharePoint group and how to add users to the particular group using SharePoint object model.

You can also check my previous posts on ECMA Client Object Model (SP.js) in SharePoint 2010 [Read here], Client Object Model SharePoint 2010 [Read here], Create list using object model in SharePoint [Read here].

Below is the full code:

SPSite site = new SPSite("http://Site URL");

using (SPWeb web = site.OpenWeb())
{
string newGroup = "MyGroup";

web.SiteGroups.Add(newGroup, web.CurrentUser, web.CurrentUser,"This is our new group");

SPGroup group = web.SiteGroups[newGroup];

SPRoleAssignment roles = new SPRoleAssignment(group);

SPRoleDefinition permission = web.RoleDefinitions["Full Control"]; //Here the group will have Full Control permission level.

roles.RoleDefinitionBindings.Add(permission);

web.RoleAssignments.Add(roles);

// Add users to this group
SPUser newUser = web.AllUsers[@"Administratoe\Fewlines4Biju"];

group.AddUser(newUser);
}

The above code will create a group and add a new user to the group.

Thursday, January 10, 2013

How to get Absolute URL of List using SharePoint object model?

In this post we will discuss how to get absoulte URL of a list using SharePoint object model.

You can also check my previous posts on Get 14 hive file path by using SharePoint 2010 object model [Solution here], Add safe controls programmatically in SharePoint 2010 [Solution here] and Add items to SharePoint list using PowerShell [Solution here].

We can use the SPUtility class to retrieve the absolute or full URL of the SharePoint list.

Wednesday, January 9, 2013

Delete SharePoint List using PowerShell

In this post we will discuss how we can delete a SharePoint list using PowerShell.

You can also check my PowerShell articles on Get System Accounts using PowerShell, Backup and Restore site collection using PowerShell, Switch from classic to claims authentication in SharePoint 2010.

Below is the code to delete a SharePoint list using PowerShell.

Tuesday, January 8, 2013

Programmatically set a user as the Site Collection Administrator in SharePoint

In this post we will discuss about how to set a user as the Site Collection Administrator in SharePoint programmatically.

You can also check my previous articles on ECMA Client Object Model (SP.js) in SharePoint 2010, Get URL value SharePoint hyperlink field and Client Object Model SharePoint 2010.

string siteUrl = "http://Site URL";
string strUserName = "DomainName/UserName";

Thursday, January 3, 2013

Benifits of SharePoint designer

In this post we will discuss some of the benifits of SharePoint designer.

You can check my previous posts on Create views using SharePoint designer 2010, Create list using SharePoint Designer 2010.

SharePoint designer is a very powerful tool for developers and power users. There are some features of SharePoint designer 2010 like below:

- Administrators can decide per site collection what exactly a power user operating SharePoint Designer is permitted to do. Check this article for more information on this.

- The new ribbon-based Office 2010 environment is now context sensitive. Means the option will come according to the tab you chose rather showing all options.

- It’s easy to create pages, pagelayouts, lists, and workflows etc.

- It’s easy to create content types and use them immediately for a list or library.

- In assets library you can store and deploy resources such as images, stylesheets, and support files.

- You can get the list views as XSLT and modify the views by editing the underlying XSLT.

- You can get access to external data sources such as web services, databases, XML files, and scripts.

- You can easily create BCS data sources, modify then and use them.

- You can create and modify list workflows, site workflows, and reusable workflows.

- You do not need vast knowledge to work with SharePoint designer.

You can check how To Hide Ribbon From Anonymous Users in Sharepoint 2010 here.

Modify SharePoint list using PowerShell

In this post we will discuss how we can modify SharePoint list using PowerShell.

You can also check my previous posts on how to add items to SharePoint list using PowerShell , PowerShell commands for SharePoint database and Powershell script to get SharePoint feature IDs.

Below is the PowerShell command to update a SharePoint List.

$site    =     new-object Microsoft.SharePoint.SPSite("http://site URL")

Tuesday, January 1, 2013

Which SharePoint 2010 objects should not be disposed

In this post we will discuss about what are the SharePoint objects which should not be disposed explicitly.

You can also check my previous posts on Detecting Memory Leaks in SharePoint 2010, Disposing SharePoint Objects and Client Object Model SharePoint 2010.

Below are some objects which should not disposed:

SPSite site = SPContext.Current.Site;

SPWeb rootWeb = site.RootWeb;

SPWeb web = SPContext.Web;

SPWeb web = SPContext.Current.Web;

SPSite site = SPContext.Site;

SPSite site = SPContext.Current.Site;

Next we should not dispose objects used in a feature receiver like:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWeb web = properties.Feature.Parent as SPWeb;
}

The below objects should not be disposed.

SPWebEventProperties.Web

SPListEventProperties.Web

SPListEventProperties.List.Web

SPItemEventProperties.ListItem.Web

- Those objects used with personal pages:

The Microsoft.SharePoint.Portal.WebControls.IPersonalPage interface has two properties that return SPSite and SPWeb objects, respectively: IPersonalPage.PersonalSite and IPersonalPage.PersonalWeb.