Programmatically determine Parent Web’s Absolute URL from SharePoint Client Object Model ListItem

Ok, after a frustrating while of trying to figure out an easy way to get the FULL (Absolute) URL for a ListItem’s parent web using the SharePoint Client Object Model I discovered one thing for sure: There are an abundance of ways to easily find the ServerRelativeUrl for many objects in the Client OM, but that is not what I needed.

After talking to a co-worker, we finally found an easy way to get the parent web’s absolute URL when dealing with at Client OM ListItem.  The key is looking at the Context.

Assuming that you have a variable called “item” that represents an SP Client OM ListItem, you can get the full URL for the parent web like this:

 

string parentWebAbsUrl = item.ParentList.ParentWeb.Context.Url;

Sometimes it’s the simple things that get you.  Hope that helps you save some time!  Thanks for reading.

Programmatically determine List Type in SharePoint Client Object Model

If you would like to programmatically determine a List Type in C# using the SharePoint Client Object Model, then all you need to do is compare the list’s BaseTemplate, which is an integer identifier, to one of the ListTemplateType enumeration values—casting it to an int as seen below:

bool isDocumentLibrary ;
using (ClientContext clientContext = new ClientContext(baseSiteUrl))
{
    Web web = clientContext.Web;
    clientContext.Load(web);
    List list = clientContext.Web.Lists.GetByTitle(listName);
    clientContext.Load(list);
    clientContext.ExecuteQuery();

    if (list.BaseTemplate == (int)ListTemplateType.DocumentLibrary)
    {
        isDocumentLibrary = true;
    }

}

That’s all there is to it.  Now you can take this and modify it in any way that you need to make list type determination more dynamic, if you aren’t just needing to compare to a single ListTemplateType as shown above.

CustomAction Link on Subsite Redirects to Parent Site—SharePoint 2007

I recently had a problem where a Custom Action link that we had added to a SharePoint subsite’s “Create” page was pointing to the relative URL of the parent site.  I discovered that it was because, without a “scope identifier” on the UrlAction element of the CustomAction, the relative URL will default to the root site of a site collection.  So, to fix the problem I added “~site” to the beginning of the URL as you can see here:

<CustomAction Id="CreateCustomPage" GroupId="WebPages"
     Location="Microsoft.SharePoint.Create" Sequence="400"
     Title="Page from Template" Description="Creates a branded page."
    
RequireSiteAdministrator="True"
     I
mageUrl="/_layouts/images/ltblnkpg.gif" >

 <UrlAction Url="~site/_layouts/CustomDirectory/CustomPage.aspx"/>

</CustomAction>

Without including the “~site” statement this will, apparently, default to the root of the site collection, which means your subsites will redirect back to the root site without it.  After adding this everything worked fine.  All of my subsites go to the proper relative URL of their own.

Andre Vala has a great blog post that discusses SharePoint Custom Actions in greater detail.  This blog also explains the other items that you can place at the beginning of the UrlAction’s URL besides ~site (i.e. ~sitecollection and others), and it helped me to figure this problem out fairly quickly.

Technorati Tags: ,,,,,,,,,

Windows Live Tags: WSS,MOSS,CustomAction,Subsite,Parent,SharePoint,Custom,Action,UrlAction,Microsoft

Adding Table Cell Borders to Empty Cells in a SharePoint DataFormWebPart

If you’ve ever used a DataFormWebPart in SharePoint Designer 2007 with a border on the table, then you may have run into the problem of empty table cells loading without borders.  This causes your table to look very strange in the browser.  Well, here is a fairly simple work around to fix the problem.  All you need to do is add a script block to the xslt in SharePoint Designer that will basically put a space inside all of the cells.  Since this forces the cells to not be empty, they will all render with borders.

Here is the script block and some quick screenshots to demonstrate how it works.

<script type="text/javascript">
    document.write("&amp;nbsp;");
</script>

Here is how the table will render without the script block if there are empty cells:

Add the script block inside of the td’s just after the xsl:value-of tags that contain the SharePoint field names that you have included in your DataFormWebPart:

Here is what the new page with blank cells should look like:

Technorati Tags: ,,,,,,,,,,,,

Windows Live Tags: WSS,MOSS,Table,Cell,Borders,SharePoint,DataFormWebPart,Designer,script,forces,Here,text,Cells

SharePoint 2007 site is Blank in Internet Explorer 8

I recently installed SharePoint Server 2007 on my Windows 7 64 bit development machine, and after setting up my first Web App and Site Collection my test site would not load in Internet Explorer 8 or in SharePoint Designer 2007, although it would work fine in Firefox.  Now the screen would load blank in IE8 after asking for authentication about 3 times.  In SPD2007, it would ask for authentication seemingly endlessly until I just hit cancel, and it would never load the site.

At first, after asking and searching around, I thought that the loopback issue with IE8 may have been causing the problem, but even after double checking everything in that area I still had the same issue.  Also, I wasn’t getting the 401.1 screen, as is usually the case with the loopback issue.  If you are having that problem, then you should check out this post

Finally, a colleague of mine, Phillip Wilkins, told me that he fixed the blank screen issue by enabling Windows Authentication in IIS.  That fixed it!  Thanks, Phillip.

Here are some quick instructions with screenshots to show you what I did:

  1. Open IIS Manager (I do this: Click Start, type "iis," and then click enter).
  2. Click on Authentication under the IIS section.
  3. If Windows Authentication is Disabled, then click on it and then click on Enable under the Actions menu on the right.  You should now see that Windows Auth is enabled, and hopefully this has fixed your problem.
     

Missing “Create or extend Web application” Link in SharePoint Central Administration

I recently did a clean install of Windows 7 64 bit on my development machine.  I used Bamboo Solutions’ WSS on Vista tool to install SharePoint Server 2007 on it; however, when I navigated to Central Administration there was no “Create or extend Web application Link” there.

Well, at first I thought it may be a permissions issue, but everything seemed to be in place there.  I also made sure to right-click Central Administration from the Start Menu to “Run as administrator,” but that didn’t fix it either.

Then I realized that I hadn’t installed Service Pack 2 for SharePoint Server.  Microsoft suggested that I install Service Pack 2 for WSS 3.0 first, which I did, and that fixed the issue.  Then I went ahead and installed The 2007 Microsoft Office Servers Service Pack 2, and everything is running great now.

Technorati Tags: ,,,,,,,,,,,,,,

Windows Live Tags: Create or extend Web Application,Service,WSS,MOSS,SharePoint,Central,Administration,Bamboo,Vista,Server,Pack,Microsoft,Office,Servers,Solutions

stsadm –o uninstall – Don’t do this!

Well, at the risk of sounding like a complete idiot, I’ve chosen to share my experience with you in order to help save you from some problems later.  I needed to force an uninstall of a feature from my development machine.  Well, this isn’t an stsadm command that I have had to use much, so I didn’t remember exactly what the command was.  The command is “uninstallfeature", by the way.  However, I was thinking that it was “uninstall”. 

So, at this point I thought I’d type in “stsadm –o uninstall” and hit enter so that it would tell me what arguments I needed to include, as you can see in the below screenshot with “addsolution".

 

Obviously, this isn’t the best practice for how to find the arguments for an stsadm command; however, I knew that it would work if I was missing any arguments (see “Important Note” below).,

The Big Problem

Now, here is the BIG problem.  Since I had the wrong command (“uninstall” instead of “uninstallfeature”), I got to enjoy a wonderful learning experience.  The stsadm command “uninstall” doesn’t have to have any arguments, so if you type it in and press enter, then it will just start to run.  And do you know what it does?  That’s right:  It uninstalls SharePoint from your machine WITHOUT asking for any confirmation.  Lesson learned.

Important Note

By the way, to avoid this problem altogether you should always do what I did not do: put “–help” after any command that you wish to see the parameters for.  For example: stsadm –o uninstall –help

Technorati Tags: ,,,,,,,
Windows Live Tags: moss,wss,feature,development,SharePoint,stsadm,uninstall,uninstallfeature

SharePoint Designer 2007 Workflows—KYSPUG

Thanks to everyone who attended my presentation on SharePoint Designer 2007 Workflows at the Kentucky SharePoint User Group last night.  We had a great turnout and had lots of great interaction.  I want to give a special thanks to Jeremy Sublett of Composable Systems and Greg Kamer of Mirazon for their selfless efforts in running this user group for us.

You can download the slide deck HERE

Here is a quick synopsis of the presentation:

  • What are Workflows?
  • Out of the Box WSS and MOSS Workflows
  • SharePoint Designer Workflows
    • The parts of a SPD WF
    • The ootb actions
    • The wf files that are created
    • The wf forms that are created
    • The browser screens for interaction with the wf
    • Common Problems, Issues, and Limitations

Thanks!

Technorati Tags: ,,,,,,,,,,,,,,,,

Windows Live Tags: SharePoint,Designer,Workflows,KYSPUG,Kentucky,User,Group,Jeremy,Sublett,Composable,Greg,Kamer,Mirazon,MOSS,Problems,Limitations,Systems

Windows Live OneCare Problem

Windows Security Center was showing me the following error when I woke up this morning along with my Malware Protection having a “yellow light” rather than green.

Windows live OneCare is on but is reporting its status to Windows Security Center in a format that is no longer supported.  Use the program’s automatic updating feature, or contact the program manufacturer for an updated version.

Thanks to Kevin Hau for His Post about a fix that has been released for this issue.  I have included the 32 bit and 64 bit links here as well.  This was a quick and simple fix that worked great.  As Kevin points out, you will need to download the exe and Run it as Administrator.

32 bit fix:
http://download.microsoft.com/download/E/F/4/EF4F2FE5-2E02-4DA1-8E68-3DC3035CEF52/WscGracePeriodFix32.exe

64 bit fix:
http://download.microsoft.com/download/E/F/4/EF4F2FE5-2E02-4DA1-8E68-3DC3035CEF52/WscGracePeriodFix64.exe

Technorati Tags: ,,,,,,,

Windows Live Tags: Live,OneCare,Problem,Center,error,Malware,Protection,status

TFS—Server has committed a protocol violation

This may seem like a no-brainer to some, but I beat my head against the wall for a while with it.  If you are trying to get the latest version from Team Foundation Server for a project, and you get an error stating that the Server has committed a protocol violation, it may be due to Windows Live Family Safety if you have it installed.  As soon as I turned Windows Live Family Safety off, I could get latest version with no errors.  I actually just decided to completely uninstall it.  I just wanted to try it out to see how it would work for my kids.  Moral of the story—Windows Live Family Safety is probably not a good idea on a development machine.

Follow

Get every new post delivered to your Inbox.

Join 107 other followers