How to Fix Quick Edit for SharePoint lists after migration from SharePoint 2010 to Sharepoint 2013

Once again with annoying problem in SharePoint. The problem will most likely occur after you have migrated a content database from SP2010 to SP2013. Thanks to the internet the solution is to make sure that list views have in ther JSLink property the following file in them: clienttemplates.js

Thanks to the following site for the tip on how to fix it:

http://www.rickvanrousselt.com/updating/

Here is a sample C# code that will fix the problem. Using powershell I was unable to get a hold of views in lists after the migration.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;

using Microsoft.SharePoint;
namespace SP2013MigrationListFix
{
class Program
{
static void Main(string[] args)
{
using(var site = new SPSite(ConfigurationManager.AppSettings["site"]))
{
for (int siteCount = site.WebApplication.Sites.Count - 1; siteCount >= 0; siteCount--)
{
Console.WriteLine();
Console.WriteLine("----------------------------------------------------------------------");
SPSite innerSite = site.WebApplication.Sites[siteCount];
Console.Write("Site: " + innerSite.RootWeb.Title);
try
{
for (int webCount = innerSite.AllWebs.Count - 1; webCount >= 0; webCount--)
{

SPWeb web = innerSite.AllWebs[webCount];
Console.WriteLine();
Console.WriteLine("Web: " + web.Title);
try
{

for (int listCount = web.Lists.Count - 1; listCount >= 0; listCount--)
{
SPList list = web.Lists[listCount];
Console.WriteLine("Web: " + list.Title);
if (list != null)
{
Console.WriteLine("View count: " + list.Views.Count);
for (int x = list.Views.Count - 1; x >= 0; x--)
{
SPView view = list.Views[x];
Console.WriteLine("View name: " + view.Title);
Console.WriteLine("JSLink before fix: " + view.JSLink);
if (String.IsNullOrWhiteSpace(view.JSLink))
{
view.JSLink = "clienttemplates.js";
view.Update();
Console.WriteLine("JSLink after fix: " + view.JSLink);
}

}
}
else
{
Console.WriteLine("List not found");
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + " " + ex.StackTrace);
}
finally
{
if (web != null)
web.Dispose();
}
}
}
finally
{
if (innerSite != null)
innerSite.Dispose();
}
}

}
Console.ReadLine();
}
}
}

Advertisements