Skip to main content

Elumenotion Blog

Go Search

 
Elumenotion > Elumenotion Blog
Posts and musings about SharePoint, eLumenotion, and random whatnot.
How to Copy Feature Elements in Visual Studio SharePoint Solutions

This is a continuation of the previous post, Save Site As Template + Import SharePoint Solution Package == Love.

Once you've extracted your field, content type, and list instance, you are ready to incorporate the element manifests and related resources into your main project. In this example I have a Web Part named HypotheticalPart and a solution named HypotheticalWebPart.

First I need to open the solution's folder in Windows Explorer.

To review, the solution that contains my other features looks like this:

I open that solution's folder in a second instance of Windows Explorer and copy the Content Types, Fields, and List instances folders to the clipboard.

And then paste them into the first Explorer window.

 

To complete the job, I go back to the HypotheticalWebPart solution in Visual Studio and click the Show All Files button in Solution Explorer.

This reveals the folders I copied previously. I simply click each of them and select Include In Project.

 

That's it! The feature elements are now in my project and included in my feature.

Save Site As Template + Import SharePoint Solution Package == Love

Say you're working on a new solution that requires certain elements like fields, content types, and list instances to provide data to a Web Part or some other custom functionality. In this post I'll show you how to create features to provision all of those elements in only a few minutes.

Consider the list shown below. It's based on the Links list and is bound to a content type named Fun Link. Note that this could just as easily be based on the Custom List template.

The site content type, Fun Link, contains a custom site column, Classification, that provides a set of choices.

Getting this into Visual Studio is easy. Open up the Site Settings page and click the Save site as template link.

Give your template a name. It doesn't matter what name you choose because the template is just an intermediate step that you'll throw away when you are done. If you choose Include Content, your new feature will recreate the list data.

When the operation completes, follow the links the your site's Solution Gallery and save the resulting WSP to your local machine.

Next, open Visual Studio and create a new project. Select the Import SharePoint Solution Package template.

Next choose either Farm or Sandbox deployment. In this example, either works fine.

The SharePoint Customization Wizard displays. You don't want everything in the wsp, just the items you need to recreate the custom list. Press CTRL+A to select all the items and then SPACE to deselect everything. Now you are ready to select only the items you need. In this case you need the Fun Link content type.

The Classification field…

The Fun Links list instance…

And the ListsFun Links_pages module.

 

Once you have the set of items you need selected, click Finish. Visual Studio will display the warning shown below telling you about all sorts of dependencies. You don't need any of them because they are all fields from the core fields feature and are always available on every site. Click No and your done!

Here is a screen shot of the new solution in Solution Explorer.

At this point I probably need to include the features in my main solution. Read How to Copy Feature Elements in Visual Studio SharePoint Solutions to see how it's done.

SharePoint 2010 End User Training Site

I'd like to thank the folks over at fpweb for providing the hosting for my newest SharePoint 2010 sitehttp://www.thesharepoint.com.

The site contains over ninety (90) short how-to articles that I wrote to help end users get up to speed on as authors of SharePoint 2010 wikis and publishing sites. I hope you find it useful!

If you would like a copy of the site's pages as a sandbox solution that you can customize to train your own users, send me an email!

Here is a screen shot of the current version. I still have some branding work to do!

SharePoint 2010 Fixed Width Master Pages Revisited

This post is an update to this post about fixed width pages I wrote when SharePoint 2010 was still in beta. If you follow the instructions in that post you'll get a fixed width page, but it will have an unnecessary (and ugly) vertical scroll bar in the page's main content area. The problem is in a function in init.js, FixRibbonAndWorkspaceDimensions. You can read about the work this function does in this post about ribbon positioning. FixRibbonAndWorkspaceDimensions does exactly what it says, but if you change the vertical layout of your page or add a footer it will give you fits. It does math and changes the size and position of various div elements independently of your CSS!

Here are the basic steps I use to create a fixed width page in the released versions of SharePoint Foundation and SharePoint Server 2010. You will almost certainly need to do more than this based on your specific design, but this should get you started. Note, this un-floats the ribbon. If you want to achieve the dynamic positioning FixRibbonAndWorkspaceDimensions provides, you'll need to recreate it with your own script against your own element identifiers.

Find the following <DIV>

<div id="s4-workspace">

Change the id attribute to something else like:

<div id="my-workspace">

Add the appropriate styles to your CSS as follows:

<style type="text/css">

    body.v4master { 

        overflow:visible;

        background-color:blue

     }

     #my-workspace    

     {

        margin-left: auto; 

        margin-right: auto; 

        width: 960px;

    }

    #s4-mainarea

    {

        background-color: white;

    }

</style>

 

This is what it looks like on a stock Team site.

SharePoint REST (ODATA) is Insecure

SharePoint 2010 includes a number of new services to allow interoperability with other systems and to make it easy to create rich Internet applications. Among these is SharePoint's ODATA implementation provided by the ListData.svc service. Overall, I think the REST is an awesome lightweight alternative to formal SOAP. Unfortunately, the implementation SharePoint provides opens a large attack surface that makes it very easy to discover the information for every user in a site.

Unlike alternative interoperability services like the traditional SOAP based services and the SharePoint Client Object Model, you must access the ListData.svc with an account that has Browse User Information permission. Consider a scenario where you want to allow a system external to your organization to read and write items in a site. You can create a permission level that allows this interaction by granting:

  • Add Items
  • Edit Items
  • Delete Items
  • View Items
  • Use Remote Interfaces
  • Open

An account with this set of permissions allows the use of the Client Object Model and some of the SOAP services to the external system to read and write list items and documents. However, the account can't browse the site's contents because it hasn't got View Pages permission, nor can the account access information about the other accounts with access to the site.

SharePoint's WCF Services implementation, ListData.svc, will not work with the above set of permissions. To make it work, you must grant Browse User Information permission.

There are probably many scenarios where you can justify this, but I personally think that a data interchange technology that reveals the accounts with access to the data store is best avoided considering that the alternatives don't have this flaw.

I hope this is fixed soon, because I'd love to use REST with SharePoint and I will as soon as Microsoft makes it possible to harden SharePoint REST (OData) security. At the moment I think it would be irresponsible to do so in most of the scenarios where REST is attractive.

1 - 5 Next
Follow me on twitter!
The Atlanta .NET User Group
  Archive
  Archive (Calendar)
  Skinner Created Themes
  New Skinner Download
  New Skinner Tutorial

 ‭(Hidden)‬ Admin Links


©  2009 Elumenotion, LLC  |   SharePoint Training, SharePoint Consulting and SharePoint Staffing
8075 Cavendish Place | Suwanee, Georgia 30024 | + 1 (888) 653-5021