Thursday, September 24, 2009

What happened to my SharePoint Usage Analysis Logs?

Recently, I went to check my usage analysis logs and noticed that they were practically empty. No new data in weeks. I know that it was working before, but what changed? What's going on here?

I double checked that everything was enabled in CA, the SSP and in the site settings, and everything was still good. I also noticed that my Log location was D:\UsageLogs. I remember setting that up, so i went and looked at the logs. There was data, but only for the CA site. After some checking, I realized what was going on.

Make sure that all your App Pool accounts have Access to write to that location. For me, only CA had the correct rights. After giving the WSS_WPG and WSS_RESTRICTED_WPG and WSS_ADMIN_WPG groups Write permission to that folder, the logs immediately started filling up. No errors in the event logs were being created for me, or else I would have noticed this a long time ago.

Conclusion: Just give all your SharePoint accounts Admin access on your servers, it'll save you a LOT of headaches. Or, even better, just run everything under one account! HAHA, no, don't actually do this, but always check permissions when things aren't working as you expect.

Friday, August 7, 2009

Oh NO! I deleted a site that I shouldn't have!

There is no recycle bin for sites. You probably know this, or you or your users found this out the hard way. This has happened to me more than once, and is the topic of a previous post about removing the 'delete this site' link.

Let's stay that you haven't done that, and you don't have a nice SharePoint backup solution that will let you easily restore deleted content. A user has just deleted a site and has come to you to get it back.

Possible solutions:
Solution 1:
Copy your backups(you have those right? :P ) to another SharePoint server and create a new Web Application using that DB. That site should now have the content that you lost. Migrate it back over to your production portal.
This is a solution, but migration can be a pain the butt. Also, it assumes you've got backups. You'll lose all your version history, and information about created and last modified. If your site is small enough you might be able to make a template out of it and rebuild a new site from there. You might even be able to use stsadm to backup and restore. Both of those options will run into trouble if your site is too big or complex.

Solution 2:
Roll back the database to a time before this disaster happened. This solution will work if you don't have backups(I think) :) and everything will seem as if nothing happened. The down side is that you will have lost everything that has happened before the roll-back point. Hopefully you were alerted quickly to the problem.
First, make a backup of your transaction logs. if you already have backups, this should be enough. If you don't, you'll want to backup the site as well.
Next, Restore a Database. Give it a new name, and pick a time that you know to be before the problem happened(but not too far back or else you'll lose more data). Choose your live database as the place to restore from. You should see it list your backup's. If you didn't back up your transaction log, you'll only be able to restore to the last backup. That is why it is important to backup your transaction log before you start.
Once the restore is complete, you'll have a copy of the DB from before the problem happened. detach your production DB, and rename this restored copy to the production name. You should be good to go.
You may want to shut down the site when you do this so that no new data is uploaded, since it will be lost. If done correctly, you should be able to restore the site very quickly, but it depends on how big your content DB is and how much traffic you get.

Good luck! And now go delete the "delete this site" link from your _layouts/settings.aspx page so that users can't do this again in the future :P

Wednesday, July 15, 2009

Add webpart to newform, DispForm and EditForm pages

Lists and Doc libraries both have Edit and DispForm pages. These pages have webpart zones on them, and adding your own webpart is possible. For some reason, sharepoint doesn't want to let you do it(the Edit Form Site action is grey'd out).

to get around this, add:

to the end of the URL. It will put the page into the browse to add a webpart view. You should be good to go from there.

Tuesday, July 14, 2009

Error Code Gotchas due to Policy Settings

I run into a few problems on almost every SharePoint install.
David Szabo has put together a great post on some of the common ones:

I've also run into issues with search not being able to search itself. This is due to a registry setting to prevent the server from DOS'ing itself. Make sure you add all the possibly URL's that your site is running to the registry setting.

One more thing that always seems to come up a few months after the SharePoint portal has been up and running causes IIS to lock up. You'll get lots of errors in the event log for 6398, 7076, and 6482. You also won't be able to administer IIS. This has to do with two processes trying to access IIS admin service at the same time.

Install IIS Hotfix KB946517 and restart. This should fix the issue.

Problems with the timer service can also be caused by the scheduled task service being disabled. You'll re-enable it and it will turn off again. This is due to a group policy setting shutting it down. Have whoever manages the policy settings disable that setting on your sharepoint machines.

Errors with DCOM settings:
The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID - Error 10016
Check out:

I'm sure there will be more to come as I remember them.

Wednesday, July 1, 2009

Add Webparts Popup missing links and buttons

After a few days of modifying the CSS and master pages for SharePoint and thinking everything was good I found the Add Webparts popup had lost it's buttons and the Advanced Link!

Tracking down what's going wrong can be tricky. This page uses the same CSS as the rest of your site, so good luck tracking down what you did. Also, this page doesn't work in Firefox, so using FireBug isn't an option(more on that later). And worst, IE won't let me right click and get Page Source!

Fortunately, someone else has hit this problem:

This person did the work to track down which page is used: /_layouts/webpartgallerypickerpage.aspx

Going directly to the link will let you us FireFox and Firebug to track down the problem. For me, I was setting the height of the page to Auto, not 100%. This caused the buttons and advanced link to appear near the top of the page, and behind the box that lets you pick webparts. I simply added:


to my CSS file, and everything was fixed. :)

Wednesday, April 15, 2009

View all Site content Blank after Import

Recently, A coworker and I had to move some sites around after a previous contractor setup the site with a bunch of different site collections and other junk that had to be removed as the site was moved to production.

Instead of moving the whole database, we only wanted to move a certain group of sites, so we used stsadm to export the sites and import them on the new server. After Import, we noticed that the the Quick Launch bar showed the correct lists, and they worked fine, but if we went to the "View All Site Content" link, nothing showed up other than the recycle bin.

Not sure what was going on here, but we were able to fix it. Here's the process we went through:

On the New server, backup the site.
Move the site(or change the URL) to something like _old.
import the site to the original site's URL.
If everything looked good, delete the _old site.

Maybe something else was going on here, but it works now.

Wednesday, March 11, 2009

Disable Site Deletion

Have you had a user delete a site, and then complain that it's gone? I have! The solution is to disable the ability to delete a site!

Simply add this line of code to the core.js, or application.master, or anywhere else that is going to get loaded by the settings.aspx page. There is probably a dozen places you could add this code.

NOTE: I haven't tested this out, but at worst, all it's going to do is find the Delete web link, and hide it on the page. It doesn't actually change the page, just the display of the page. You could disable javascript in your browser and it would re-appear.


This basically says, find the "Delete this site" link, and turn off the display of that row in the table.

If you do need to delete the site, you could always just go directly to the _layouts/deleteweb.aspx page on that site, and click to delete.

Hopefully this will save you a few headaches.

You could get fancy, and change the link's HREF to be a mailto: link to your
helpdesk or sys admins. That way, if they want to delete a site, they will have to send you an email. Then you simply remove everyone's permissions. They'll think it's deleted, but you could easily bring it back if you needed to.

Good Luck!

Wednesday, February 11, 2009

Attachments and Customized Forms

Microsoft has relased a new hotfix for Sharepoint:

This allows you to use attachments and customized forms. Without this hotfix, the customized form you would get a popup error saying: "This form was customized not working with attachment. "

Supposedly, this hotfix fixes the issue. You will probably have to rebuild your forms though.


There is another hotfix related to this issue. There are two parts, one is to update your Sharepoint server, the second is to add data to the forms. I've tested this out and it works!;en-us;953271&sd=rss&spid=11373

Tuesday, February 3, 2009

Dynamic drop down lists on Forms

Often, customers want options in one field to be driven by a different field in the form. For example, Categories and sub-categories. If the user picks A in field 1, field 2 should be filtered to only show options A1,A2,A3, etc.

Since sharepoint doesn't have a good way to do this, and I dont want to build a custom user control, javascript is the solution.

First, you'll want to create a function to clear out all the options from the second drop down list. Something like:

function clearSubCat(){

var subCat = getTagFromIdentifierAndTitle("select","DropDownChoice","Sub-Category");

var opts = subCat.options;

var len = subCat.length;
for (i = 0; i <len; i++)

If you google getTagFromIdentifierAndTitle, you'll find a nice blog article and the source for this function.

Second, you'll need a function to re-populate the drop down list given the value of colum 1:

function populateSubCat(){
var subCat = getTagFromIdentifierAndTitle("select","DropDownChoice","Sub-Category");
var catList = getTagFromIdentifierAndTitle("select","DropDownChoice","Category");

var cat = catList.options[catList.selectedIndex].text;

case "Directives":
var optA = document.createElement('option');
optA.text = "DOI";
optA.value = "DOI";


You'll have to add more cases to the switch statement.
Basically, this gets the DOM object for the two categories, and inserts values into the sub-category based on the value in the category.

Third, you'll want to setup the javascript to set the onChange event for the Category drop down list.

function filterSubCat(){
var catList = getTagFromIdentifierAndTitle("select","DropDownChoice","Category");
catList.onchange = function() {populateSubCat()};

I call the filterSubCat() function in a content editor webpart.

In my case, the Drop down list values were limited and Static. If your lists are more dynamic this may not be the best solution.

Thursday, January 15, 2009

Creating custom Item ID's

A customer would like to use custom ID's to track items throughout the site. These ID's are something like:

I would like to delete the Title field and use this throughout the system, but this causes some problems. I can't rename Title without renaming Title on every item in the entire site. I can hide title, and create my own column, but then I have to create custom datasheet views everywhere because Title is the only field that has a link to the new form, and has the drop down list available. I suppose I'll just have to use the Edit link everywhere.

Creating a custom ID field should be easy right? Just use a calculated field you say!
Sadly, it's not that simple. First, I would like to have the ID portion padded to 4 spaces. ie. 0001, 0021, etc. This causes some troubles. Second and most important, the ID field is set after the calculated field is set. If you do this strictly through a calculated field, you'll end up with TYPE_DATE_0000.

Ok, so then do it with a workflow! This solves the ID being 0 problem, but the Designer workflows don't seem to support the formula's needed to create the Date in a YYYYMMDD format. If you just use Created as the date, you'll end up with something like: TYPE_1/15/2009 8:43:03 AM_0001. UGLY.

The solution is to use a hybrid of both. Create a calculated field that is:
Next, create a workflow that is activated on New item created for you're list. The workflow will need two steps.
The first step is to create the necessary padding for your ID. Mine is something like:

If ID < 10 set variable 'padding' = '000'
if ID >=10 and ID <100 set variable 'padding' = '00'
If ID >=100 and ID <1000 set variable 'padding' = '0'

Next, set the prefix = 'TYPE' or whatever you want. If this is dynamic, you'll need another step to set this to be what you want.

Use the string builder to put all your variables together. [PREFIX]_[createDate]_[padding][ID]

Set your Identifier field to the new variable you created with the string builder. DONE!

Tuesday, January 13, 2009

Changing Title Site Column name

When creating a new site content type you are required to choose a type that it will inherit from. The simplest type is a list content type who's parent is 'Item'.
The problem is that you'll end up with a default column called 'Title'. Great, what if I don't want a column called Title?

This column is inherited by every list item across the site. If you change the name, the entire site will change! What really gets you, is that you can't change it back!
The form checks and see's that the name 'Title' is reserved. It doesn't care that you're not using it anymore.

If you've already done this, There is a way to change it back. (

Here's the basic idea:
Open the page that lets you change the name and save it to your computer(the complete page). Open the page, and remove the javascript that does the check:

if (doesFieldNameConflict(DisplayName))
return false;

Open the page, rename it back to "Title" and hit save. SharePoint isn't smart enough to realize that the page lives on your computer and not the server. It will let you change it back.

The right solution is to edit your site content type, and change the 'Title' field to be hidden. Then create a new column called Title, or whatever you want to name it.

The problem this creates, is that whenever you have a view of the list, the Title field is the one that is used to link to the DispForm, and also has the drop down list of options to modify that row.
The only solutions I've seen so far is to create your content types with a feature. This isn't a good solution when you're trying to prototype something though.

Importing and Exporting Webparts

Frequently, I find myself creating XSLT data view webparts because the out of the box layouts don't cut it.

I found that if a webpart is added to the page using the browser, then edited in designer and converted into a XSLT view, it can cause problems. I was no longer able to export the webpart and import it to another page.

Unfortunately, to work on a webpart in designer, it has to be on a web part page since you have to break the page from the template. I then exported the webpart and imported it to a normal publishing page. The webpart imports, but causes the page to error out. You must then edit the page in the maintenance view and remove the offending webpart(the last one listed, since they are listed in order they were added to the page).

So, add your webparts in Designer as a Dataview, edit them in designer, and move them later. Sorry if you're trying to edit one you created in the browser and converted to an XSLT view, just start over and save your self a headache later.

Friday, January 9, 2009

Customizing List Forms using Javascript

A cool feature you can get access to using SharePoint Designer is the ability to create your own List forms. You can create a new NewForm page, with certain fields removed, or add the form to another page, allowing users to create or edit a new item without having to dig into the appropriate NewForm or EditForm.

In Designer, it's under the Insert -> SharePoint Controls -> Custom List Form.

I've been using this recently, and I wanted to be able to manipulate the fields using JavaScript. I would like to pre-fill certain fields with data, and hopefully create a better user experience.

So far, I've found two pages to be helpful:
Accessing and Changing Form fields -

There is an example about halfway down for grabbing a people Picker field. Looks like it can only grab the first one?

I also needed to be able to grab and edit a Radio Button option
One solution I found was at:

This solution didn't work for me, it was looking for:

somewhere in the parent's innerHTML. My customized forms don't have that. I changed the code to look up another level and look for the Field name there. Seems to work ok. Example below:

function SetRadio(tagName, identifier, title, value) {
var len = identifier.length;
var tags = document.getElementsByTagName(tagName);
for (var i=0; i < idstring =" tags[i].id;" namestring =" tags[i].name;" type ="="" identifier ="="" tagparenthtml =" tags[i].parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.innerHTML;">'+title) > -1) {
var radioButtons = document.getElementsByName(nameString);
var radioValue = "";

for (var x=0; x < radioButtons.length; x++) {
if(radioButtons[x].parentElement.title == value){
radioButtons[x].checked = true;
radioButtons[x].checked = false;
return null;

Tuesday, January 6, 2009

Workflows and "The data source control failed to execute the insert command. "

I recently took over the design of a site that makes heavy use of Designer created workflows and custom Edit Forms.

While trying to figure out how the system worked, I ran into this error when starting a workflow:
"The data source control failed to execute the insert command. "

After googling around for a few minutes, I found this:

I had never actually seen the remove workflow page on a list before. Interesting. I was able to remove the workflow from the list. Once I re-opened the workflow and saved it, the workflow starting working again. Weird. But at least it works again.