Category Archives: Views

What is Focus on Content in SharePoint Online 2013?


You may also be interested in: O’Reilly - SharePoint 2010 at Work


 

Editor’s note: Contributor Alexandru Dionisie is an Internet Professional and Technical Writer. Follow him @AlexDionisie

In SharePoint Online 2013, in the Promoted Actions toolbar among Share, Follow, Edit, Sync commands, there is another command called Focus on Content.

What it does

  • when activated, it closes the left panel (the one with the picture, recent documents, navigation links, etc.

More exactly, it closes the left Navigation Pane for the current page.

If we exit the page and the Focus on Content is On, when we return to that page, the Navigation Pane will still be closed.

Before:

2013-07-15-SharePointFocusOnContent-01.png

After:

2013-07-15-SharePointFocusOnContent-02.png

SharePoint: My View on Views


You may also be interested in: O’Reilly - SharePoint 2010 at Work


 

Editor’s note: Contributor Ellen van Aken is an experienced intranet adoption manager. Follow her @EllenvanAken

Don’t you like a nice view? So, next time you have configured a page with a web part in default view, consider if this is really the best possible way to display your content for your audience. Can you make better use of the sorting, grouping, filtering and other capabilities to make your content easier to digest for your users?

Here are a few situations that may help you make a decision:

How collaborative is your site?

If you want to display read-only content for a large audience, do not show edit options. Although edit links, item names and buttons are security-trimmed, having no edit options will allow you to design and view the page exactly like your audience sees it.

But if you have a site where you share documents with your team, make sure there are plenty of edit options on every page to stimulate online collaboration.

What is your content?

If you have a project team or your department working on various documents, it is wise to show the latest document on top. (Sort by Modified, descending). That will show everyone what has happened in the site recently.

But if your content is manuals or instructions, and fairly static, you may want to sort on title, either alphabetically or numerically. Please keep in mind SharePoint is a little weird with sorting numbers in text – please use 01, 02, …10 to avoid sorting your stuff as 1, 10, 11…etc.

And do you really need to add “Manual” or “Policy” in every document name?

How many people contribute to your site?

If just one or two people are editing in your site, the Created By or Modified By columns will display the same names over and over again. That does not add much value. Another column may give your audience more information. You can also leave out that column and make your page appear less cluttered.

But if you have many people working in your site, the Created By and/or Modified By, as well as the date, ARE important. In highly collaborative sites, the Modified and Modified By may be the best option.

For issues however, the Created By and Created give more information. And you may want to sort issues on Due Date – Ascending, displaying the items with the earliest dates first.

How much space is available?

When your list or library is the main content on the page the center web part zone will be the best place to display it. You will have enough horizontal space to add a few meaningful columns.

But when the main real estate of the page is taken up by an explanatory text, and the official policies are listed as “additional information” in the right column, you only have room to display a title…so keep that short and sweet!


Example of explanatory text and a small sidebar for related information.
The text is my own invention and not an existing policy!

If you have limitations on vertical space, you may want to display your information grouped and collapsed, with a filter and/or an item limit.

I often use “Last 5 or 10 documents” on a homepage, where I use Modified Descending combined with Item Limit = 5 or 10.

Who has to do it?

For Tasks lists, Issue lists or if you need to manage the life cycle of your content, a view with Assigned To, Created By or Modified By = [Me] is essential. It allows you to see (and act on) the items that you are responsible for.

I sometimes use a “My” view to hide content. It is not security, and it is not water-tight, but it helps to make content less visible for others.

Need to know how much or how many?

Displaying Totals can be very useful. I often use a Count to check if all documents have copied over successfully from one location to another, or to see how many tasks or issues are awaiting my attention. I have also used the Sum to show or how much money was generated by a project.

Avoid using them on a grouped list, because Totals take up a lot of vertical space and can make your content appear very cluttered. And annoyingly, SharePoint can not do a Sum on Calculated Columns.


Notice how much space the “Sum” (or “Count”) takes on a grouped view!

It is worth spending time on this.

In many of the solutions I have created, I have discussed the Views in much detail with the owners and end users. Some want to read and act on the relevant information quickly, without having to open each individual item. Some may need a “first glance”insight” overview. Some may need a very specific filter for data analysis. For different audiences and purposes you can use different views. I think Views are one of the best features of SharePoint!

In CRM in a Team Site, we had a.o.:

  • “All open Incidents” with a “Sum” on the homepage to show immediately how much money was involved with complaints.
  • “My Incidents” for everyone that was involved in reviewing or approving incidents. It was based on “Assigned to me”.
  • “Incidents per Transport Company”, allowing the process owner to see the performance of each transporter.
  • “Still Open after 14 days”, helping to reduce turnaround time, etc.
  • “Credit Note in progress” overview, showing all incidents for which a Credit Note had to be issued. This helped Sales and Back Office people when they had contact with customers.

You get the idea. Discussing and creating/fine tuning Views can be a lot of work, but it will also make your content so much better to find and understand, your process so much easier, and your users so much happier!

If you need more technical/functional information on SharePoint Views, please download this ebook by Chris Poteet.

Play “Hide and Seek” in SharePoint


You may also be interested in: SharePoint Conference.ORG 2013


 

Editor’s note: Contributor Ellen van Aken is an experienced intranet adoption manager. Follow her @EllenvanAken

2013-04-28-HideSeekSharePoint-01.jpgAfter my earlier rant about people who want to secure their content for no good reason, I thought I would give some suggestions for alternative ways to hide content when it makes sense.

First let me stress that I recognize that some content is sensitive and really needs to be secured. But there is also a lot of content which is not confidential, but which you still may want to hide, to avoid information overload in general. Specific reasons may be:

  • The content is only relevant to a certain audience
  • You do not want people to influence each other
  • You want to allow people to focus on their own content, e.g. in projects or tasks lists

Next to giving permissions there are two other ways to hide content that I know of, but I will be happy to learn new ways!

1. Targeting.

In SharePoint it is relatively easy to target web parts to an audience. You can specify one or more audiences, SharePoint groups or individuals and only they will see the web part.
We have used this especially to target links on the Homepage – in the main navigation, every employee had a link to the Employee Information of his/her country.

2. Configuration.

a. Item-level permissions.
For surveys and lists, you can let people read only the items that have been created by themselves. (Advanced settings). This is nice if you do not want people to influence each other, but not very useful when you want to show the collected information to your audience. I usually apply it only in survey-type occasions.

2013-04-28-HideSeekSharePoint-02.gif
Item-level permissions in the advanced settings

b. Created by = [Me].
When not using the item-level permissions, I like to use this filter for the default public view. That way people see their own items first and are not influenced by others, and they can not easily edit other people’s content. You can have additional public views showing all contributor’s items, or the process owner can create personal views and use web parts to display content from all contributors.

c. Impossible filters that show an empty default view.
We have used “Created < 01-01-2000” as the only public view to create an empty looking document library, accessible to all employees. The documents were distributed to other (secured) sites via Content Query web parts. Of course, the owners of the documents created personal views to see all documents. The advantage for the content owners was that the owners of the secured sites could manage access for their site.

d. Hidden columns.
In older versions (e.g. SP2007) you can create views without the Edit button, and without the “Name” column instead of “Name (linked to item/linked to document with edit menu)”. This way, your readers will be unable to click on any items to see the complete item. Of course this is useless for Document Libraries, unless you only want to show that the documents are there. (Perhaps this can also be done in SP2010, but since I am the only one in my environment, I have too many rights to test this)

e. Removing web parts in the list or library.
You can remove the system web part of the list or library to avoid anyone seeing the content, including the site owner. I would recommend this only for very specific occasions, since it is very annoying to have to add the web part back every time.

f. Sending people to a non-default page after submitting data.
I often send people to a Thank You page after completing a survey or other data collection, by customizing the link. It is a nice gesture, it confirms that submission has been succesful and it allows you to give more information about next steps. It also hides other people’s responses from view.

I have also sent people from a topsite to a request form in a subsite, and after completion sent them back to the original page in the topsite. They did not have to see other people’s requests, and this way they could continue to do what they were doing in the topsite. Well, you will get the idea; you can use this with all pages within your environment.

How to do it? Your links will normally have this format:
http://IntranetName/TeamSiteName/Lists/ListName/NewForm.aspx?Source=http://IntranetName/TeamSiteName/Lists/ListName/ViewName.aspx

The part before “newform.aspx?” is the “data entry” part of the list, the part from “Source=” the location where people will go after clicking “OK” or “Finish”. You can replace the part after “Source=” with a link of your own choice. Please note this only works when you send a link in an email, use a Links list, or create a button. If you click “New Item” from the list, the link will always use the system format.

2013-04-28-HideSeekSharePoint-03.gif
Simple Thank You-page

Warning:

  • Targeted or hidden content will normally still turn up in Search. People can also see it when they have the link to the information. This is not confidential information, so it is not a problem, but it helps to be aware of it. Do not be afraid that people will go and look for this info – they do not know it is there and they probably would not care if they knew.
  • Many people do not understand the difference between targeting (visibility) and security (access/permissions), especially not that you target a web part, but secure a library or list. Be prepared for questions.
  • If you are the site owner, but you are not in the targeted audience, you will not see the content, so it will be difficult to maintain the web part. This is especially the case with Content Editor and Summary Links web parts, because they are not represented in the “back-end” of your site, i.e. the page showing all site content. This may occur when you are managing global content distributed over various “country” web parts.
  • If you target something and you are in the audience, you may forget that the content is not visible for everyone. Mention it in the web part title as a reminder.
  • Remember to discuss any targeting and personal views when handing over responsibilities for a site!

What other ways have you used to hide content without security?

SharePoint - Alpha Search


You may also be interested in: O’Reilly - SharePoint 2010 at Work


 

Editor’s note: Follow contributor Ryan Elliott @ryanelliott82

In response to a comment left to me on the page for Filtering with Web Part Connections, Kerri Abraham asked me to do a how-to on an alphabetical search of a list.  The below process will guide an end user from start to finish, Creating a Contacts list, the needed views for the alphabetical search to function, and creating the custom list to do the alphabetical search.

  1. Create a custom list and give it whatever columns you will need to keep track of…
    • Fname                         Single line of text
    • Lname                         Single line of text
    • Title                             Single line of text
    • Facility                         Single line of text
    • Address                       Single line of text
    • City                             Single line of text
    • State                            Single line of text
    • Zip                               Single line of text
    • Phone                          Single line of text
    • Fax                              Single line of text
    • Approval Status (you don’t need this unless your list items need to be approved before going live

  2. Now that you have your contact list created, you can create a view for your alpha search based on last name
    1. Click on the drop down selection for View:
    2. Next, click on Create View
    3. And then select Standard View and give it the name A
    4. Make sure the columns listed in step 1 are selected to be part of the view (or whatever columns you want visible on the default page).
    5. Set your Filter for the view to be as follows…
    6. Click OK to create the view
    7. Repeat this process for each of the other 25 letters of the alphabet
  3. Now, create another custom list to enable the alphabet shortcuts (in our case, we called this list AlphaSearch)
    1. You can leave the mandatory field Title in place, and change the default view to not display this column
    2. Next, create 25 more columns for each of the remaining letters
      1. A                     Hyperlink or Picture
      2. B                     Hyperlink or Picture
      3. C                     Hyperlink or Picture
      4. D                     Hyperlink or Picture
      5. Etc.
        • Be sure to change the Format URL as: field for each column to be a Hyperlink

    3. Once you list has been created, go back the AllItems.aspx page so that all columns are visible
    4. Next, click on New to add new items to the AlphaSearch list.
      1. You can leave the Title field blank, and make the description match the column name
      2. In the web address field – place the link to the specific view you created in Step 2 for each letter of the alphabet
      3. Click OK to save you additions

    5. Once complete, the AlphaSearch list will be setup to search your Contacts list, where the last name starts with the corresponding letter of the alphabet.
  4. You can take this one step further if you would like, and add the AlphaSearch list as a webpart to your contacts list.
    1. Open the Contacts list, and click Site Actions, and then Edit Page.
    2. Add the AlphaSearch web part above the contacts list, and click Exit Edit Mode to save the addition.

How To: Display Files in a SharePoint Library That Were Created Between a Specific Date Range


You may also be interested in: SharePoint Apps by Cybozu


 

Editor’s note: Contributor Dean Virag is a Technical Trainer for ASCD. Follow him @techtrainerdean

Author’s Note: Below is a how-to article that I wrote for a lawyer in NYC. He needed to find all documents in a document library that were created between two dates and then move them out of SharePoint and back into a networked file share.

So, he first contacted a prominent SharePoint consulting company there in NYC who said that the problem could only be handled through custom code. Then, after reading one of my posts on EUSP, he contacted me. I was able to solve his problem in about 10 minutes – using nothing but out-of-the-box functionality. It took more time for me to create this how-to article than it did to come up with the solution.

So the first part of this article is about creating a view that displays documents that were created between two different dates. The second part covers the same thing, only using Windows Explorer (in Windows 7) instead of SP.

He followed the second part and was able to get the files out of SharePoint that he needed. In the end, I did not charge him for my time (about an hour total) and I saved him from wasting thousands of dollars on a custom solution when one was not necessary.

The Problem:

Finding and aggregating files stored in folders in a document library can be a nightmare, especially when you are talking about thousands of files. The problem grows when you throw in the need to display only files that were created between two dates.

But, do not fear good SharePoint citizen! There is an easy solution to your problem, one that requires no coding and can be accomplished in a short amount of time – and here it is.

Solution 1: Display Files in a SharePoint Library View.

  1. Go to your document library.
  2. Click the Library Tools à Library tab.
  3. 2012-11-26-FilterOnDateRange-01.png

  4. Click the Create View.
  5. 2012-11-26-FilterOnDateRange-02.png

  6. Click Standard View.
  7. 2012-11-26-FilterOnDateRange-03.png

  8. Give your view a name.
  9. 2012-11-26-FilterOnDateRange-04.png

  10. Select the columns that you want to include in the view. Make sure that Created is checked. Note: Created is the date that the document was added into SharePoint.
  11. 2012-11-26-FilterOnDateRange-05.png

  12. Optional: Select a value or values to sort your view results. For example, you could choose to sort by created date displayed in descending order. The documents created most recently would be displayed at the top of the list.
  13. Add the date range to filter the results.
    1. In the Filter group, click the Show items only when the following is true option.
    2. 2012-11-26-FilterOnDateRange-06.png

    3. Select to show files where Created is greater than or equal to your desired start date. In this case we want to show all files created after September 11, 2011.
    4. 2012-11-26-FilterOnDateRange-07.png

    5. Select and.
    6. 2012-11-26-FilterOnDateRange-08.png

    7. Select to show the files where Created is less than or equal to [Today].
      Note: [Today] is a dynamic variable that will automatically use the current date.
    8. 2012-11-26-FilterOnDateRange-09.png

    9. In the Folders group, select to Show all items without folders.
    10. 2012-11-26-FilterOnDateRange-10.png

    11. In the Item Limit group, increase the Number of items to display. In this example, the view will return the documents in batches of 100 files.
    12. 2012-11-26-FilterOnDateRange-11.png

    13. Click OK to save and display your view.
    14. 2012-11-26-FilterOnDateRange-12.png

    15. A flat list of files that were created between a range of dated will be displayed in the view. However, SharePoint does not make it easy to do things like copy or move multiple files. For that, we need to use Windows Explorer!

Solution #2: Filter and Display the Files Using Windows Explorer

  1. Go to your document library.
  2. Click the Library Tools -> Library tab.
  3. 2012-11-26-FilterOnDateRange-13.png

  4. Click the Open With Explorer button to display the contents of the document library in Microsoft Windows Explorer.
  5. 2012-11-26-FilterOnDateRange-14.png

  6. Right-Click in the column header section of Windows Explorer, and select Date Created. That will add the Date Created column to Windows Explorer.
  7. 2012-11-26-FilterOnDateRange-15.png

  8. Roll your cursor over the Date Created column header and click the down triangle that appears.
  9. 2012-11-26-FilterOnDateRange-16.png

  10. A calendar will appear under the down triangle. Click the left triangle to navigate back to the month/year that you want to start filtering the files.
  11. 2012-11-26-FilterOnDateRange-17.png

  12. Once you have reached the desired month/year. Click the exact date that to begin filtering your documents and drag your cursor down to the bottom of the calendar without releasing the mouse click. Continue to move the cursor down to go into the next most recent month. Be careful, the selector moves fast! You might have to try it a couple of times to get the hang of it.

  13. 2012-11-26-FilterOnDateRange-18a.png

    2012-11-26-FilterOnDateRange-18b.png

    Click on Sept 11, 2012….

    And drag downward to select into October. Stop on the desired date.

  14. The files that were created between the selected date range will be automatically displayed, but in their folders. To view all the files outside of their folders, click the Search again in: Subfolders.
  15. 2012-11-26-FilterOnDateRange-19.png

  16. The display will update to show all the folders at the top of the list and all the documents below the folders.

    Note: A Folder column will automatically be added to show which folder each document came from.

  17. 2012-11-26-FilterOnDateRange-20.png

  18. You can now select all the files and copy them into a new location outside of SharePoint, such as a directory on your C drive, or a network shared drive.
  19. Repeat this process in all libraries where you want to filter files by date range.
  20. Paste all the desired files into the same folder.

2012-11-26-FilterOnDateRange-21.pngCongratulations, you have successfully filtered files based on a date range in both a SharePoint Document Library and Windows Explorer.

SharePoint: Did you know? Newsletter Style View


You may also be interested in: SharePoint Hosting by Fpweb.net


 

Editor’s note: Contributor Chris Stone is a SharePoint Consultant and Trainer for Sector Learning Solutions. Follow him @sharepointee

This view style’s purpose has eluded me for almost the whole time I have been working with SharePoint. I ran across it accidentally the other day while playing with a list. The problem is that it really doesn’t look that impressive until you have a visible multiple lines of text column.

What does it do? It wraps the first Multiple Lines of Text column to a second row, and each column after that will be wrapped to another row below that. This makes displaying a Multi-Line of text column much more reasonable, since normally they squish everything to the left based on how much content are in them.

It turns this:

2012-07-29-NewsletterStyle-01.png

Into This:

2012-07-29-NewsletterStyle-02.png

For those of you not familiar with where this option is located, it’s found in the modify view configuration under the style (near the bottom)

2012-07-29-NewsletterStyle-03.png

Did you know about this?

Enjoy!

How to Link Two Lists and Create a Combined View in SharePoint 2010


You may also be interested in: the only cloud-based Dev/Test solution for SharePoint by CloudShare


 

Editor’s note: Contributor Melick Rajee Baranasooriya is a Senior Software Engineer at IronOne Technologies. Follow him @MelickRajee

The following steps will allow you to join multiple listd together and create a combined view. For example, assume that you are managing a list for some events. You also have a separate participants list. Now you want to join the two lists and create a composite view.

SharePoint 2010 allows you to create this kind of view using Linked Data Source. With this approach you can create your own custom list in SharePoint.

How to Create a Linked Data source

Go to SharePoint Designer and go to the link called data sources.

2012-05-10-CombineView-01.png

Click the Linked Data Source button in the ribbon. SharePoint designer will prompt the following dialog.

Add the two lists that you want linked together.

2012-05-10-CombineView-02.png

2012-05-10-CombineView-03.png

I’m adding airline schedule and booking list. These are the two lists that I want to merge. Click next and it will guide you to another screen. You will be asked to select either

  • Merge
    • Merge is used to combine lists which have the same column definitions. For example we can say this is like a Union operation in the database.
  • Join
    • Join operation is used to link two or more lists. The lists do not need to have the same column definition. This is equal to join operation in the database.

I need to join the two lists to get the passengers for a particular schedule. I will use the join option and click finish.

2012-05-10-CombineView-04.png

Then switch to the general tab and give a name to identify the data source.

2012-05-10-CombineView-05.png

Now you are done with the linked data source.

How to create a custom view using linked data source in the SharePoint designer

I’m going to create a custom aspx in SharePoint Designer and create a view for it. Go to Site Pages and create new aspx file.

2012-05-10-CombineView-06.png

In Designer you can now see an empty aspc file.

2012-05-10-CombineView-07.png

You can now add the data source into the page. There are many ways to do this. The best choice is to Insert and then select your data source to add to the page. I’ve found that it is not always visible in the data source task pane so you you will have to go to Data View and add your data source.

2012-05-10-CombineView-08.png

This action will generate a table in the page. But we don’t need it so we’ll delete it. We will want the data source in the data source task pane. (Select all and press delete on the key board.)

2012-05-10-CombineView-09.png

Go to the task data source pane and select the columns you want to add to the page. Click add as a multiple view item.

style="text-align: center">2012-05-10-CombineView-10.png

This will generate a table for you. Click the right most column, go to table and add a new column to the right as seen below.

2012-05-10-CombineView-11.png

Now, place the mouse cursor to the column and select the second list in the data source pane and select the columns you want and click Join Sub View.

2012-05-10-CombineView-12.png

Then it will ask for the relation between columns to Join (like foreign key). Here link data using ID of the Airline Schedule.

2012-05-10-CombineView-13.png

Note: Sometimes the Join Sub view will not appear. In order to see it, click two or more columns. I don’t know why this occurs but it has happened to me several times. And this is how I managed to solve the problem.

Now you can see a composite list view in the page that you can use for …

2012-05-10-CombineView-14.png

Truncate text in list view and add mouseover preview

 

I wrote this article last month: Multi line text field in list view: Shorten text and add hovereffect to view full text.

This post is an updated version to support both SharePoint 2007 and SharePoint 2010.

Features

This solution will shorten any text column (single line or multi line) in a list view to a preset length, and append “…” to indicate that the text is truncated. If the text is shorter than the “trigger length”, the cell is skipped.

How to set up

Go get jQuery v1.6.4 from here.

Note that this is NOT the latest version. I have not had the time to find out why v1.7+ does not work.

Download the code for the file “TruncateTextInListView.js” from here Note the different versions for SharePoint 2007 and SharePoint 2010.

Upload both files to a shared document library – or a folder in the root of the site (created with SharePoint Designer). Ensure all users have read access to the location.

Put a CEWP below the list view web part, and insert this code:

<script type="text/javascript" src="/test/English/Javascript/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="/test/English/Javascript/TruncateTextInListView.js"></script>
<script type="text/javascript">
function init_TruncateText(){
	truncateText('MultilineText',50,'');
}
</script>

Note:
You must change the “src” attribute of the script tags to point to your local copies of jQuery and “TruncateTextInListView.js”.

Parameters for the function “truncateText”

  • fieldName: The FieldInternalName for single line text fields or display name for Multi line text fields.
  • initialLength: The number of characters to display.
  • inPlaceHoverText: This argument is optional and can be text to show in place of the original text – like “hover to read”.

Ask if something is unclear.

Alexander

SharePoint Developer Orientation - Part 5: Professional Development with Visual Studio

 

2011-07-17-SPDevOrientation-Part01-01.jpgGetting started with Visual Studio

This article is going to be somewhat of a diversion from the style of my previous posts. It is going to feel more basic, elementary, and possibly boring at times for some of you (sorry!). We need to set up a development environment and learn about Visual Studio’s SharePoint Tools, so please bear with me. I think these are important topics to cover in an "orientation" series, even though this information is available scattered about the internet.

The goal for this article is for readers to have a good feel for the environment they will be working in. I will cover setting up a development environment, working with SharePoint projects in Visual Studio, organizing and deploying your project with features and packages, and finally, I will wrap up with a little professional software engineering advice.

Setting up your development environment

So far in this blog series, we have only needed access to a SharePoint site, and a computer with SharePoint Designer and a web browser. With only those tools, power users can build rich applications.

For full-featured, professional SharePoint applications, however, we need Visual Studio. This requires SharePoint to be installed on the development machine. To set this up, please reference Technet and the community for instructions. In short, you will want:

  • A virtualization environment (Hyper-V, VMWare, etc.), although you could install on a physical Win7 64-bit machine
  • At least 8GB RAM (with at least 4GB allocated to the guest virtual machine)
  • Ideally, one or more SSDs or fast 7200+ rpm HDDs (host OS on one, VMs on another)
  • For best results, install 64-bit server software, and 32-bit client software (Office, browsers, etc.).
  • Install pre-requisites (SQL 2008 R2 Express+, PowerShell, IIS, etc.)
  • Install SharePoint 2010, Designer, and VS2010.
  • Install Visual Studio 2010 SharePoint Power Tools
  • Install CKS – Development Tools Edition (Server or Foundation)

Take a little time to research your options and plan your development environment.

Sandboxed Solutions

In Visual Studio, most SharePoint project types are the same. They are Empty SharePoint Projects with one or more SharePoint Project Items (SPIs) added by default. You will almost always use the Empty SharePoint Project type and add any necessary SPIs yourself. When you create a project, you will be prompted to enter a local SharePoint site to use for debugging, and choose between a sandboxed solution and a farm solution.

Many SharePoint experts will tell you to always select sandboxed and change it to farm later, if necessary. I agree with this advice, but I think there are a couple of things we need to fully understand. What are sandboxed solutions and why bother with them? They are SharePoint solutions (WSP files) that are installed into a site collection’s Solutions gallery. Anatomically, there is no difference between a sandboxed WSP file and a farm WSP file. If your solution meets certain restrictions, then it is eligible to be installed into a site collection’s Solutions gallery. The real value is that they are installable by a site collection administrator (a.k.a. “USER”) rather than a farm administrator (a.k.a. “IT”). That is why they are sometimes referred to as "user solutions" and are run by the "user code service."

When you attempt to activate your solution from the Solutions gallery, it will be validated against sandboxed restrictions. Sandboxed solutions only have access to a limited subset of the Microsoft.SharePoint namespace, are limited to the Site Collection scope, run under the current user’s security context at all times, and cannot touch the file system. Furthermore, they run in their own process and app domain with strict CAS policies (the sandbox), and SharePoint reserves the right to shut them down if they exceed configured thresholds (CPU utilization, etc.). Farm Administrators can add more restrictions via custom solution validators, increase or decrease a solution’s thresholds, or turn off Sandboxed solutions altogether.

See Technet’s Sandboxed Solutions Overview and MSDN’s Restrictions on Sandboxed Solutions article for more information. As usual, there is guidance from the community as well.

A couple more quick notes about Sandboxed solutions… First, you can use the Packaging Explorer (View > Other Windows > Packaging Explorer) to validate your package and find out if you are still within the constraints of a Sandboxed Solution:

Finally, you can change the Sandboxed/Farm status in the project’s properties window:

SharePoint Project Items (SPIs)

To add functionality to your project, you will add SharePoint Project Items (Right-click your project > Add > New Item…).

SPIs behave like folders that contain files that are functionally related. This does not represent how the files are deployed to SharePoint. The SPI abstracts deployment details to make your life easier. Some files may end up on the file system, in the content database, or not deployed at all. Every SPI has an Elements.xml element manifest file, and a hidden SharePointProjectItem.spdata file that helps Visual Studio keep track of the SPI’s files, compiled code (SafeControl entries), and how to package it all for deployment.

Let’s look at a few examples:

  • The Empty Element SPI is the basis of all the others and literally contains an empty Elements manifest.
  • The Module SPI simply places files into the SharePoint content database (in document libraries or galleries) or the file system. It adds a <Module…> xml element to the Elements.xml manifest with one or more <File…> elements that define where to place each file.
  • The Web Part SPI is essentially a pre-configured Module SPI that places the .webpart definition into the site collection’s Web Part Gallery. In addition, it has the .cs code file for the WebPart class that is compiled. This file is not deployed (in the properties window you will see a Deployment Type of "NoDeployment"), but its namespace is tracked in a SafeControl entry so that when the solution is deployed, the code is allowed to run in the SharePoint environment. You can see this in the SharePointProjectItem.spdata file.
  • The Visual Web Part SPI goes even further by defining a user control (the .ascx is placed on the SharePoint file system in the control templates folder via a module). The user control is loaded programmatically within the WebPart class (VisualWebPart1.cs file). This allows you to visually design your web part as you would a regular ASP.NET user control.

There are many other SPIs, but there is not always a pre-defined SPI for everything you might need to build. For example, there is no Custom Action SPI out of the box. You have to add an Empty Element SPI and add the necessary XML by hand. (The CKS:DEV VS Extension adds a Custom Action SPI, by the way, among others.)

Features

Features are the logical units of functionality that users can turn on and off for a particular deployment scope (site collection, site, farm, or web application). Going to Site Settings or Central Administration, a user can see the list of features they can activate or deactivate:

Visual Studio adds Features to your project for you as SPIs are added. Generally, you will have one feature for each deployment scope you need to use, but you can have as many as you want. Not all SPIs can be deployed to all scopes, though. Web parts, for example, must be deployed at the Site Collection level (because that is where the Web Parts gallery is). You will get an error during packaging if any SPIs are in the wrong features, although the feature designer does a lot to help prevent that. It is helpful to name your features with their scopes (e.g. “Web Feature”) in Solution Explorer, but definitely provide user-friendly titles and descriptions in the feature definition itself.

Feature Receivers (right-click the feature > Add Event Receiver) allow you to run code upon FeatureActivated (post-event), FeatureDeactivating (pre-event), FeatureInstalled (post-event), FeatureUninstalling (pre-event), and FeatureUpgrading (pre-event). This enables some interesting scenarios. You can programmatically create lists and other items instead of doing so declaratively in SPIs. Or get creative with an empty feature that fires off any server code you wish upon activation and/or deactivation. Another good use of feature receivers is to clean up after yourself. Not everything is cleaned up automatically when your feature is deactivated or uninstalled. Any list instances, modules (files, including web parts), or documents you deployed will be left behind. As a best practice, you should understand the disposition of all your solution’s items and plan on how you will clean up after them, if at all. See Stefan’s blog post for an example of cleaning up after yourself.

Features can have activation dependencies on other features. Users will not be able to activate your feature until the other one is activated. It is possible to automatically and silently activate a feature yours depends on, but only if it is hidden and at the same deployment scope as your feature.

Once your feature is developed and deployed, you will have a new set of challenges upgrading features. When you are ready for version 2.0 of your solution, you will have to track your changes from the baseline manually, and explicitly lay out the upgrade steps from prior versions. If you are developing a solution that needs to be maintained and upgraded over time (as opposed to installed fresh each time or one-off site-specific solutions), you have to begin version 2.0 carefully and be disciplined as you change your solution. Always remember, if your upgrade process is getting out of hand, you can write code for the FeatureUpgrading event receiver to get over a hump. Chris O’Brien has covered feature upgrading in depth in his blog, so I will refer you to him for more details.

Packages and Deployment

A package shows which features and files will be contained in the WSP file. It is concerned only with deployment… how to package up features, mapped files (files copied directly to the file system during deployment via a mapped folder rather than provisioned in a feature via a module), and assemblies into the WSP file. When you package your project from the Build menu, your output directory will contain a WSP file you can manually deploy. Solutions are manually deployed using PowerShell for farm solutions, or the web UI for sandboxed solutions.

Visual Studio does support F5 deployment, which is handy for local deployments during development, but not deployments to other environments. F5 deployment will retract your solution if already deployed, and automatically resolve conflicts. For example, if your solution creates a list, F5 deployment will remove the list and deploy it fresh. This is not the behavior you will get when deploying in a real-world scenario, so leave yourself time to test deployments!

Professional Software Engineering

As this is an orientation series, I will only briefly mention that professional software engineering practices are possible with SharePoint. You can set up a build server for continuous integration, write unit tests with mocking frameworks, secure and version your source code with TFS, etc. You know how to do this, because you’ve done it before. Developing for SharePoint does not excuse you of your responsibilities as a professional developer to create reliable solutions. There may be pressure on you to cut corners when your power user counterparts are churning out solutions a dozen at a time. You are here to play a different role and provide value in a different way. Try not to get caught up - or let your customers or bosses get caught up - in the mistaken notion that SharePoint can solve all problems fast and cheap. You get what you pay for.

Finally, let me point you to a great resource for developers. The patterns and practices crew at Microsoft put out guidance for Developing Applications for SharePoint 2010. It is currently on MSDN, but was started and developed and refined into its current state on codeplex, where you can still find some hands on labs.

Conclusion

So where do we go from here?! This almost wraps up this orientation series. Part 6 will round it off with an example of how to build a business application. It will showcase one approach that ties in all (ok, hopefully most) of the lessons of this series. If there is anything you want to hear more about, please let me know in the comments below or on twitter (@SharePointLou) or linked in (louestrada).

Thanks for reading,
Lou Estrada