No XsltListViewWebPart was found on this page

Received this error when trying to open a page/List from our disaster recover location.

No XsltListViewWebPart was found on this page

Turned out that I didn’t have the 3rd party solution installed.  Make sure you check that your features and solutions are all installed.

*Update*

Had this happen again and ended up finding my own post on Google.

The page / view would not load because of the following reasons:

  • Feature on the site was disabled.
  • The view had a custom web part and some java that referenced the feature.

Fix?

Open the site in SharePoint Designer, navigate to the broken list / library, then edit the view.  *make sure to edit the view in Advanced Mode (look in the ribbon).*

Once you have the view open, look for any web parts or custom code that looks out of place.  In my case, there was an outdated reference in the first line of the code, then a content editor web part that had some inline code.

Once I removed the extra junk, saved my changes, went back to IE and refreshed the page, all was well!

*Update 2*

Received this error when I tried to edit a lookup column.  The column was custom or created by a 3rd party.

To fix the issue, I created a new column, then used PowerShell to copy the contents from BrokenColumn to NewColumn

And then!

Because BrokenColumn was broken, I had to use PowerShell to delete it.

The code below will copy the contents of lookup column to another lookup column.


$cSite = Get-SPweb "http://sharepointed.com/sites/taco"
$cList=$cSite.Lists["Taco List"]

foreach($f in $cList.items)
{
 $uFrom = $f["BrokenColumn"]

 if($uFrom -ne $null)
 {
$f["NewColumn"] = $f["BrokenColumn"]
 $f.Update()
 }
}

This will delete the broken column.


$cSite = Get-SPweb "http://sharepointed.com/sites/taco"
$cList=$cSite.Lists["Taco List"]

foreach($f in $cList.fields)
{
 $fff = $f.Title
 if($fff -eq "BrokenColumn")
 {
$cList.Fields.Delete($fff)
 }
}

Why Wait for Document to be Unlocked by Document Editor Sucks

If you are using the SharePoint Designer action wait for document to be unlocked by document editor, you may be aware of it’s shortcomings.  Like what?  Well, if you submit a form or document to the library, this action fires.  If the form/document happens to be a little slow getting to the library, the workflow will pause for another 5 minutes!  ¡No bueno! 

What I did to get around this was, write a little inline PowerShell script as my first action in the Workflow.  The script loops every 5 seconds to see if the form/document has been unlocked.  5 seconds vs 5 minutes, there is a large difference.

How? If you don’t already have the iLove SharePoint Workflow Actions installed, do it! The actions can be downloaded here: http://ilovesharepoint.codeplex.com/ .  (read the documentation)

Once installed, modify your Worflow or create a new one. I replaced the lame Wait for Document to be Unlocked by Document Editor with a Execute PowerShell action. The PowerShell code is below.


if(-not(Get-PSSnapin | where { $_.Name -eq "Microsoft.SharePoint.PowerShell"}))
{
 Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

$site = Get-SPweb "http://sharepointed.com/sites/taco/"
$mList=$site.Lists["The Library"]
$item = $mList.GetItemById([<strong><span style="text-decoration: underline;">%Current Item:ID%</span></strong>])

$Lock = $item.File.LockType

while($Lock -ne "None")
 {
 start-sleep -s 5
 $Lock = $item.File.LockType
 }

Please notice the line $item = $mList.GetItemById([%Current Item:ID%]), Current Item: ID is the ID of the item that started the workflow.  This is key to Workflow action working!

*update*

It’s also a good idea to modify your default view and other views to only show workflow items that have a completed status.  How?  Edit the view, scroll down to the Filter section, select the column that has your workflows name in it.  The next drop down should be ‘is equal to‘ and the text box, input the number five 5.  5 represents the Completed workflow status.

SharePoint Completed Workflow Status

SharePoint Completed Workflow Status

Monitor Content Database Size with Powershell

Simple question.
How large are the content databases?

To solve this, I created a list in Central Administration, and wrote a quick PowerShell script to update the list with my Content Database size(s).

List Name: Content db Size
List Columns: Title, db name, db size (Type = Single line of text)
View: Show Title, db name, db size

PowerShell Script:

if(-not(Get-PSSnapin | where { $_.Name -eq "Microsoft.SharePoint.PowerShell"}))
{
      Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
$adminwebapp = Get-spwebapplication -includecentraladministration | where {$_.IsAdministrationWebApplication}

$siteUrl = $adminwebapp.Url
$listName = "Content db Size"
$spSite = new-object Microsoft.SharePoint.SPSite($siteurl)
$spWeb = $spSite.OpenWeb()
$spList = $spWeb.Lists[$listName]
foreach ($item in $spList.items) { $deaditem = $splist.GetItemById($item.ID); $deaditem.Delete(); }

$webapps = Get-SPWebApplication
foreach($webapp in $webapps)
{
    $ContentDatabases = $webapp.ContentDatabases
    foreach($ContentDatabase in $ContentDatabases)
    {
    $ContentDatabaseSize = [Math]::Round(($ContentDatabase.disksizerequired/1GB),2)
	$addItem = $spList.Items.Add()
	$addItem["Title"] = $webapp.DisplayName
	$addItem["db name"] = $contentdatabase.name
	$addItem["db size"] = $contentdatabasesize
	$addItem.Update()
    }
}

$spWeb.Dispose()

The script is doing the following actions:
Truncate the Content db Size list.
Looping through all the Web Apps.
Updating the Content db Size list with the Web App name, db name, and size.

Taking this to the next level:
Update the existing list item, opposed to truncating the entire list.
Setup a workflow to email you if a db size is greater than X.

*update*

What if you want to get all the Site Collections in a Content Database?
 

$sites = Get-SPSite -Limit All  -ContentDatabase YourContentDatabaseName

foreach($site in $sites)
{
	$siteSize = [math]::round(($site.usage.storage/1GB),2)
	Write-Host $site.url "--" $siteSize
}

Use Links List to Add Navigation to a Page

Say you have a lot of lists and libraries on your site. How do you easily allow people to navigate your site?

What I’m going to do is, create a List, then use web parts on a page to display the list items in groups.

Create a new Links List
Site Actions –> View All Site Content –> Create –> Links
I named my list Navigation.
Once you have created the list, click on the List tab in the ribbon, then select Create Column.
Column name: Category
Require that this column contains information: Yes
Type each choice on a separate line: Fruit and Veggie (you can enter whatever you want)
Click OK.

Once you have setup the list, add a few items to it.
Simply click +Add new link to add an item.

As you can see here, I’m adding a link to my Onion library, description is Onion, and my Category is Veggie.

I went ahead and added two more items to the list.

In the next step, I’m going to create a new web part page to house the navigation. You can use an existing page and skip this step.

To create a new page
Site Actions –> View All Site Content –> Create –> Web Part Page
Click Create, then on the next page, you will want to give your page a name.
Then select the layout you want to use. For step, I select the first layout listed.
Lastly, select a Save Location for your page and click Create.

When the page opens, you will have some web part zones on the page. These zones are used to add web parts to.
Click Add a Web Part, the ribbon will change to display the available web parts. In the Categories section, select Lists and Libraries, then select Navigation (or whatever you named your Links List). Once selected click Add.

Now we want to edit the web part to filter what is displayed, and change the web part name.
To edit the web part, move your mouse over the top right corn of the web part. You will then see a small triangle appear, click on it. This will bring up the options menu for the web part. To edit the web part, click Edit Web Part.

Look at the right side of your screen, you should see the web part proprieties window.
In the Appearance section, I changed the name to Veggie.

Scroll up a little.

In the List Views section, click on Edit the current view. When the Edit View page opens you will see an option that allows you to add or remove columns from the web parts view, and others. Scroll down to the Filter section. The first dropdown box, select the Category field, leave the next dropdown to is equal to, and then type in the next box the value you want to filter by.

Scroll to the bottom, and click OK
Once you return to the page, you will now see that the web part is filtered by the value we entered into the filter section of edit view page.

To add another web part, edit the page again, and follow the above steps to filter by another value.

Final product.

Let me know if you have any questions.

Failed to cache field with id “{ }”, overwrite=0

Workflow failed with this error:
Failed to cache field with id “{blah-dae2-4908-80cd-blah}”, overwrite=0

In my list (A) I had a lookup column pointing to another list (B). In B, I had updated a field from Single line of text to Multiple lines of text. The workflow did not like this update. Once I recreated the field as a Single line of text, the workflow started working.

Coercion Failed: Unable to transform the input lookup data into the requested type.

SharePoint Workflow error:
Coercion Failed: Unable to transform the input lookup data into the requested type.

Using a workflow, I was trying to set the value of a Lookup field. Where I went wrong was, setting the Lookup field to a field other than the ID column of the Lookup List.

What??

Quick example:
Created two lists.
Taco and Taco Topping.

Taco Toppings fields: Title, Meat, Cheese, Salsa

In the Taco list, I added a Lookup field to Taco Topping, also adding Meat, Cheese, and Salsa fields.

Now for the workflow.

On the Taco list, create a new SharePoint Designer workflow.

The workflow will contain the following actions: Set Workflow Variable and Update List Item

First we will create the variable
click inside of Step 1, from the ribbon click on Action, then find Set Workflow Variable.
Once it’s added to the workflow step, click on blue workflow variable text.
I named my variable Taco ID and set the type to Number.

Next click on the blue value text.

Here I’m querying the Taco Topping list for the ID field, and filtering by the Title column of the Title fields of Taco and Taco Topping. Think of this a simple SQL select statement with a where clause. Select ID from Taco Topping where Title = Current Item: Title

Next we will add the Update List Item action.
Click below the Set Variable action, then add the Update List Item from the Action button in the ribbon.
Click on the blue this list text.

Here I’m updating field T to the ID from workflow variable Topping ID.
This is what will drive updating our Taco list to the toppings from Taco Topping.

Your workflow should now look like this.

Publish the workflow, all done!

*Be sure to change your workflow settings (in the ribbon) if you want the workflow to run when a new item is added or changed.*

is locked for

Two different errors, same fix!

File is locked for editing by domain\username
is locked for shared use by domain\username

Before you do this, make sure you have a copy of the file that is locked. Open the Library in Explorer View and create a copy of the file, or save a copy to your desktop.

Bottom line, you will need to either write a PowerShell script to update the CheckoutExpires field in the Content Database or go directly into the Content Database and update the record. I know, you should never play with the SharePoint databases, great!

First we will need to get the correct Content Database and ID for the locked file.

if(-not(Get-PSSnapin | where { $_.Name -eq "Microsoft.SharePoint.PowerShell"}))
{
      Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
 
$site = Get-SPweb "http://sharepointed.com/taco"

$spList = $site.lists["Soft Taco"]
$i = $spList.GetItemById("14")

$SQLconn = $i.Web.Site.ContentDatabase.DatabaseConnectionString

$id = $i.UniqueId

What I’m doing is getting the database connection string and the ID of the file.

Now, crack open SQL Server Management Studio. Navigate to the Content Database that we identified in the $SQLconn string above. Create a new Stored Procedure and paste in the following script.

Now you will need the value from $id.

Select * from dbo.AllDocs 
WHERE Id = '89c87af8-758b-4186-ffaa-c78a13695aec'

Once you run the above query, you should see the record that is locked. Make note of the CheckoutExpires field, the is what we are going to update.

Next you will want to run the update script that will unlock the file.

UPDATE dbo.AllDocs SET CheckoutExpires = '2000-01-22 13:24:47.000' 
WHERE Id = '89c87af8-758b-4186-ffaa-c78a13695aec'

Refresh your browser, and the file should now be unlocked.

Get The Size of a Document Library

“How large is my Document Library”

This was an odd one to crack. For reporting reasons, our team wanted to track the item count and size growth of a Document Library. Sound easy?

if(-not(Get-PSSnapin | where { $_.Name -eq "Microsoft.SharePoint.PowerShell"}))
{
      Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

$SPsite = Get-SPsite "http://www.sharepointed.com/sites/taco/"

$dataTable = $SPsite.StorageManagementInformation(2,0x11,0,0)
foreach($x in $dataTable.Rows)
{
	if ($x.LeafName -eq "MyTacoLibrary" -and $x.Directory -eq "sites/taco")
		{
			$LibSize = [Math]::Round(($x.Size/1GB),2)
			Write-Host $LibSize
		}
}

Thanks you Jon for guiding this script.