Subscribe

A Couple of Things I Learned Early

Written on February 14, 2008 by Bryan

These are two posts from my internal company blog that I felt were worth sharing publicly.

Deleting Master Pages from the Master Page Gallery

It’s not as easy to delete a master page from a site’s master page gallery as you might think. Simply clicking the “Delete” option from the drop down menu doesn’t work because you will almost always get this error:

This item cannot be deleted because it is still referenced by other pages.

You could spend a lot of time trying to find the pages that reference this master page, but you won’t find them because it’s highly possible that there are none!

Thankfully, SPD comes to the rescue (for once) allowing you to delete the master page using a fun workaround we found on this blog.

Just use SPD to open the site in question and find the master page gallery (under _catalogs/masterpage). Create a folder in here called “deleteme” and move the master page that you’d like to delete into the folder. Then delete the folder. Voila! It’s gone. Thanks SPD!

Getting the Account Name from a “Person or Group” Field

We actually found something useful in the Community Content section of an MSDN page. This doesn’t only apply to Workflow Task Properties either. Basically, this code snippet will convert the underlying string value of a “Person or Group” type field in a SharePoint list(which looks something like “12345#;Some Name”) into the correct account name in the form of “<Domain>\<Username>”.

SPFieldUserValue userValue = new SPFieldUserValue(workflowProperties.Web, retrievedFieldValue);
string userName = userValue.User.LoginName;

In this case the SPWeb is coming from the workflowProperties, but I think it just needs the one that the SPList lives in. Any SPWeb may even work.

Get a Trackback link

No Comments Yet

You can be the first to comment!

Leave a comment

You must be logged in to post a comment.