Dev Team Assemble

Evil beware!
Add to Technorati Favorites

Archive

Tag: SharePoint

I was trying to install install SharePoint 2007 onto Windows 2008 r2 and was getting a strange error referencing KB article 962935. Funny enough this article is not live yet so it left me a little unhappy. Apprarently Microsoft does not support the distributed SP1 installation package of SharePoint for this version of the OS. Turns out Jei Li posting on his msdn blog detailing how to go about creating a slipstreamed installation for SP2 on this server Click here for the article. Basically the steps are (pretty much word for word from Jei Li's blog):

  • Install .Net Framework 3.5 SP1 in the features applet
  • Copy the installtion media contents to a folder on the computer (c:\install)
  • Download the WSS x64 SP package and the MOSS 2007 SP2 x64
  • Delete everything inside Updates folder in the install folder you setup.
  • Open a command prompt,  change directory to the folder you put the downloaded patches, and run the following two commands: 
    • wssv3sp2-kb953338-x64-fullfile-en-us.exe /extract:[Path to installation bits]\Updates /quiet
    • officeserver2007sp2-kb953334-x64-fullfile-en-us.exe /extract: [Path to installation bits]\Updates /quiet
  • Delete the wsssetup.dll filein the updates dir. This is a very important step so please don’t miss it.
  • If you also need the Cumulative Updates to be applied when install SharePoint, download the latest Windows SharePoint Services 3.0 and SharePoint Server 2007 Cumulative Update packages and extract them into Updates folder like step 4.
  • Your slipstream build of SharePoint Server 2007 is done!
  • Go and install it on your Windows Server 2008 R2 box, after the installation, the site version will show 12.0.0.6421 or possibly a higher version.

Please reference Jei Li's post for furthur instuctions.  I only posted all the steps here because things have a mysterious way of dissappearing or not appearing at all on Microsofts site.

After doing all of this everything seems to be fine...seems to be :)  

Links

Technorati Tags: , , , , ,

One of the things I was working on today was trying to get an actual image from the library was that initially I was expecting to get a PublishingImage.  All the samples on MSDN and the ones strewn about the web refer to using the ImageFieldValue and getting it from a field in the SPListItem.  Like outlined on MSDN :

  // Retrieve the current value from an SPListItem with a
  // column of the ImageField type with the name imageFieldName
  ImageFieldValue currentFieldValue =
        listItemWithImageField[imageFieldName] as ImageFieldValue;

The problem is this only works for images that are in a list, like the PublishingRollupImage of a page that links to an image in the Site Collection Images library.  The actual images in the library are stored as documents (Referenced using SPFile) so in order utilize them I need to extract the information out and create an image tag for it...like so:

 
     ImageFieldValue imageValue = new ImageFieldValue(
          string.Format("<img src=\"{0}\" alt=\"{1}\" />",
          file.Url, file.Title == null ? string.Empty : file.Title));
 

Now that I had the ImageFieldValue it was easy to work with. I could manipulate many aspects of the image using this object and then save it for rendering using ToString(). Funny thing is for my purposes (ImageGallery xml generation) I didn't even end up needing this code after all...frustrating but a good learning experience.

Props to Phanat Chan as he did the initial development on this.

Technorati Tags: , ,

So I got this error the other day when putting together a dev site collection usign varations:

An error was encountered performing this operation. You may re-try the operation, and you may need to clean up the half-created data first before re-trying. If the problem persists, please contact your system administrator

This was actually a fairly easy fix for me.  I simply had to enable the publishing features in my site.  Which is funny...because they should have been on but I must have overlooked that.  :)

Technorati Tags: , , , ,

Day three was a lot of fun as I got to spend three hours in the labs and ran through some pretty cool stuff.  Linq to Sharepoint, Upgrading sites, REST API etc.

As far as the sessions went I was hoping the MultiLingual sites session was going to make me happy with some great news about variations.  Instead it seems to be status quo on that system with MS playing the line that you need to plan ahead for this...makes sense but not always possible.  The multi language user interface or MUI for all the chrome is available in every site now and you can switch languages off the site actions bar.

MindSharp had an awesome evangelistical session in the big room on Developiong with REST and LINQ in Sharepoint 2010.  This was another really great session on developing against the new Client Object Model, the Server OM, the ListData.svc REST service.

All in all it was another good day...If I didn't have to spend thenight doing homework it actually would haev been mouch more fun :|

Technorati Tags: , ,

The second day of the conference was great and a couple of sessions really stood out above the others in my mind....there was a great session in the morning on web part development and some of the new things coming up in that.  AJAX is baked into SP now which is great but there is also a bit of a learning curve surrounding XSS and making sure we understand cross-site scripting and how SharePoint really cracks down on this.

There was an amazing session on SharePoints new COM or client object model that exposes all sharepoint objects to the client (.NET CLR, silverlight and javascript).  Essentially we will be able to a LOT more work on the client side which makes me feel warm inside.

I finally got to play around with SharePoint 2010 in the labs which was great.  I was dying to get a feel for the product because it feels weird listening to all these sessions without actually having your hands on it.  I definitely will be spending more time in the labs.

The Huey Lewis and the News Beach Party was a lot of fun but I left there feeling a little...drunk for lack of a better word.  Good times in vegas...

Technorati Tags: , ,

Yesterday started with a hangover...for me.  On Sunday there was a SharePint event at the Eye Candy bar in the middle of Mandalay Bay and I was one of the  unfortunate souls whohappened to have drank too much :|   The Keynotes were pretty cool...nothing overly stand out there was a lot of talk about the new product and moving forward and a couple of demos that probably were a little too long.  Truth be told my butt hurt from sitting through almost 3 hours of Keynotes so I was happy when it was done.

In the afternoon the actual session began.  for me it was the Whats New For Developer Overview, Visual Studio 2010 Tools Overview and Web Content Management in SharePoint 2010.  We covered a lot of ground in the first two and and they were very much an overview of all the features available.  Things like running SP on the desktop client (x64 win7 or vista), visual studio 2010 build, debug, deploy, the developer dashboard, Linq to SharePoint (YES), the ribbon and sandboxed solutions.

The final session (the web content management one) was a bit of a disappointment.  It was a level 300 session and seemed like they dumbed it down for beginners, i mean they were teaching us how to make web pages via the UI.   There was some interesting stuff in the presentation but at no point did they really dive in and demo things like the variation model improvements or content deployment fixes they have made.  It was just alluded to.

Either way it was a pretty good day...met some great people from all over the world so far and I hope that continues.

Technorati Tags: , ,

I came across this problem recently. Its a little strange and only happened once I changed my base webpart class to inherit from Microsoft.SharePoint.WebPartPages.WebPart. There seems to be two fixes for this problem that I implemented:

  • remove the XMlNamespace from class declaration
  • Use a .dwp file instead of a .webpart file in your feature folder

Technorati Tags: , ,

For the last little bit I have been working on learning how to package up all site infrastructure into a single feature.  All of this is pretty straight forward and I didn't really have any issues.....UNTIL  I tried to get lookup columns working.

Using CAML

I did some reading on the subject and apparently you can do all of this using CAML alone.  I came across a post from Josh Gaffery supporting this claim, but I simply could not get this working...so i gave up after spinning my wheels on it for longer than I wanted to.  Josh's approach is to use the list URL as opposed to the GUID that links the column to the source list and he has put up an update explaining it further.  Nonetheless....didn't work for me.

Using Feature Receiver

I knew that at this point I would have to take the feature reciever approach and modify the fields in place or create them.  I found two sources that both take different approachs to this problem.

  • Chris O'Brien has put together the a project on CodePlex that will create the lookup columns at activation time.  This actully sounds like a pretty good approach but unfortunately it didn't work for me.  I dont know if there is something wrong with my environment but I encountered a few errors doing this...things like the fields not rendering on the page layouts and getting the "The local device name is already in use. (Exception from HRESULT: 0x80070055)" error.
  • Waldek Mastykarz has a great post on creating the columns via code here.

Basically I took a hybrid approach to doing this by mixing the two approaches mentioned above.  I created a custom XML file that I deploy into the layouts directory and then use a feature reciever to read the xml content and create lookup columns based on this.  I also added a deactiving event to remove the fields when the feature is deactivated.  Heres the feature reciever code:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            using (SPSite site = properties.Feature.Parent as SPSite)
            {
                string contentTypes = null;
                string listName = null;
                string fieldName = null;
                string groupName = null;
                string staticName = null;
                string lookupFieldName = "Title";
                bool mult = false;
                bool required = false;
                string filePath = properties.Feature.Properties[
                   "ColumnDefinitionPath"].Value;
 
                XmlTextReader xReader = new XmlTextReader(
                  HttpContext.Current.Server.MapPath(@"~\_layouts\" + filePath));
                while (xReader.Read())
                {
                    if (xReader.LocalName == "Field")
                    {
                        #region Get values from attributes
                        if (xReader.MoveToAttribute("List"))
                        {
                            listName = xReader.Value;
                            xReader.MoveToElement();
                        }
                        if (xReader.MoveToAttribute("Name"))
                        {
                            fieldName = xReader.Value;
                            xReader.MoveToElement();
                        }
                        if (xReader.MoveToAttribute("StaticName"))
                        {
                            staticName = xReader.Value;
                            xReader.MoveToElement();
                        }
                        if (xReader.MoveToAttribute("Group"))
                        {
                            groupName = xReader.Value;
                            xReader.MoveToElement();
                        }
                        if (xReader.MoveToAttribute("LookUpField"))
                        {
                            lookupFieldName = xReader.Value;
                            xReader.MoveToElement();
                        }
                        if (xReader.MoveToAttribute("ExistInContentTypes"))
                        {
                            contentTypes = xReader.Value;
                            xReader.MoveToElement();
                        }
                        if (xReader.MoveToAttribute("Mult"))
                        {
                            bool.TryParse(xReader.Value, out mult);
                            xReader.MoveToElement();
                        }
                        if (xReader.MoveToAttribute("Required"))
                        {
                            bool.TryParse(xReader.Value, out required);
                            xReader.MoveToElement();
                        }
 
                        #endregion
 
                        SPFieldLookup lookup = CreateLookupField(
                          fieldName, groupName, required, mult, site.RootWeb,
                          site.RootWeb.Lists[listName], lookupFieldName, staticName);
                        if (contentTypes != null)
                            foreach (string s in contentTypes.Split(','))
                            {
                                LinkFieldToContentType(s.Trim(), (SPField)lookup);
                            }
                    }
                }
 
                xReader.Close();
 
            }
        }
 
        public static SPFieldLookup CreateLookupField(
          string fieldName, string group, bool required, bool allowMultipleValues,
          SPWeb w, SPList lookupList, string lookupField, string staticName)
        {
            w.Fields.AddLookup(fieldName, lookupList.ID,
               lookupList.ParentWeb.ID, required);
            SPFieldLookup lookup = (SPFieldLookup)w.Fields[fieldName];
            lookup.AllowMultipleValues = allowMultipleValues;
            lookup.LookupField = lookupField;
            lookup.StaticName = staticName;
            lookup.Group = group;
            lookup.Update(true);
            return lookup;
        }
 
        public static void LinkFieldToContentType(string contentType, SPField field)
        {
            using (SPSite site = SPContext.Current.Web.Site as SPSite)
            {
                SPContentType ct = site.RootWeb.ContentTypes[contentType];
                ct.FieldLinks.Add(new SPFieldLink(field));
                ct.Update(true); // will update children
            }
        }

As you can read from the above code the xml file would need to have a node like below for each lookup column:

 
<Field
         Type="Lookup"
         List="Access Type"
         Name="AccessTypeColumn"
         StaticName="Access_x0020_Type"
         Group="Infrastructure"
         ExistInContentTypes="THIS IS A COMMA DELIMITED LIST OF CONTENT NAMES"
         LookUpField="Title"
         Mult="TRUE"
         Required="FALSE"
        />
 

The Final Project

So here are all the pieces of my infrastructure project. Notice the placement of the lookupfields xml file...this is because the layouts directory is setup as a virtual directory for every sharepoint site and we can read files from there without a permissions problem.

12/TEMPLATES/FEATURES/myfeature/lists.xml this contains the source lists for the lookup fields
12/TEMPLATES/FEATURES/myfeature/contenttypes.xml this contains the content type definitions MINUS the lookup fields
12/TEMPLATES/FEATURES/myfeature/sitecolumns.xml this contains all the other fields included in the content types
12/TEMPLATES/FEATURES/myfeature/feature.xml the feature def
12/TEMPLATES/LAYOUTS/myfeature/lookupfields.xml this contains all the lookup fields that need to be provisioned

Hopefully this helps anyone who's been having problems getting this going. And a big thanks to Waldek, Chris and Josh for their posts.

Technorati Tags: , , , ,

I started getting this error recently on my development box after I started using WSP Builder.  I really like this program but I was a little put off by this error.  Obvisouly it is recycling  the worker process or something along those lines (too lazy to look it up).  I am fine with it when it comes back online after a few seconds but I was having instances where it was hanging there...stuck in 503 limbo. 

Turns out the problem is the application pool is stuck in a stopped state and the fix is simply enough to restart it.

Technorati Tags: , , ,

While working on my sharepoint development machine today I was mucking about with variations and doing a proof of concept.  Now I know they worked before but for some reason when I created a new page in the source site they were not being propagated through to the variation label sites.  In Centeral Admin under the Timer Status I found that the Variations Propagate Page Job Definition and the Variations Propagate Site Job Definition were both stuck at 0% and Initialized, see below:

variations

Seeing this, I now knew that the Timer service was not creating my variation pages and sites so a quick check under the windows services control panel applet  revealed that the Windows SharePoint Services Timer Service had been shut off.  Turning this back fixed my problem.

Technorati Tags: , , ,