Wednesday, August 29, 2012

Unable to find the default edit form for list...

So Exporting a Site as a Template and Importing it into Visual Studio can be very useful but only if it works!

I was trying to use this method to create a List and a Library Instance so I could include it into my existing solution.  I did this and it appeared as though everything worked well until I tried to upload a document in the library or create a new list item...then I would get a nasty error about
"Unable to find the default edit form for list My List"
So I looked back in the definition and for the list there was this SharePoint Module inside that was named 'Listslist_name_here_pages'and had a Elements.xml inside it with some information about the DispForm, NewForm and EditForm...

Perfect, so for the list I included this module just as it was in the other solution and low and behold it worked...but then the Library didn't have a module inside it...WTF!!! Then some more snooping lead me to see that there was a Modules folder that had 4 Modules with the corresponding names each with their own different Elements.xml files!
LibraryNameForms_1033_STS_doctemp_word
LibraryNameForms_Features_DocumentLibrary_doclib
LibraryNameForms_pages
LibraryNameFormsMy Custom ContentType_1033_STS_doctemp_word
NASTY!!!

So, being a slave to SharePoint I set out to duplicate these four modules just as they were in the imported solution...no dice...but then I got to thinking about how this works and I snooped into the Scheme.xml of the list instance and found this....
<Forms />
What?!? that's not right...so I blew away all my precious modules I worked so hard on and switched the above one line in the Scheme.xml for this...
<Forms>
  <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
  <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
  <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
</Forms>
WOW! Its magic! just like It should be...and a much nicer, cleaner solution.

More information about the Scheme.xml can be found here

Tuesday, August 21, 2012

SharePoint 2010 Products Configuration Wizard "Configuration Failed"

Ever spent a full day (or more) trying to get SharePoint 2010 Products Configuration Wizard to work properly?

It seems like every time I have to run this thing it fails with that lovely "Configuration Failed" error message...and this is of course after 15-20 min and 92.57% or whatever random percentage it pulls out of the air.

You can dig through the logs, the "Upgrade-datestamp-timestamp-randomnumber-error.log" log file often has much more informative information in it that the "PCDiagnostics_datestamp_timestamp_randomnumber.log" that the wizard recommends.

So, after that then what?

Never fear, Command Prompt is here!

Run this command from a SharePoint 2010 Management Shell prompt and 9 times out of 10 it will work...I don't know why i don't just do this to start with.
PSCONFIG.EXE -cmd upgrade -inplace b2b -force
there are many different switches you can add to this command all of which may or may not help but this is the one that i use the most.

Tuesday, July 31, 2012

HEY!!! Who changed my Helper.dll?

Ever want to share a class in Visual Studio without having the overhead of the good 'ol "Helper.dll"?

Try this instead...
Adding an Existing Item as a Link

It is a very rarely used and under appreciated feature of Visual Studio that I didn't know existed until recently.

Here is why this is good:
  • You have less DLL's
  • You still have the ability to share classes.
  • When you compile your code you always have the latest version of the class unlike a copy of the class.
  • Once you compile, that build will always have that version of the class until you build again.
  • Sharing Is Caring...OK, OK, I am done


Downfalls:
  • I can't think of one can you?

Thanks to my coworker and this blog post for helping me realize this possibility.

Friday, July 27, 2012

Ode to SharePoint Designer

Just a little fun here...
You have the right to use SharePoint Designer,
Anything you save or modify will not be backed up.
Some unexpected results are to be expected.
If you cannot afford a Developer, then you may not wish to proceed.
Do you understand these flaws as I have described them to you?
Just kidding SPD...but seriously, stop trying to help...if I wanted your silly __designer:Preview tags then i would ask for them.


If you got here via search looking for answers I am sorry...try these sites:
SharePoint Designer 2010 inserts "__designer:Preview" and "__designer:Values" attributes upon reopening of Master Pages
Sharepoint Designer 2010 adding/generating __designer preview tags – a fix to solve this issue

SharePoint 2010 Event ID 6482 Application Server Administration job failed for service instance Microsoft.Office.Server.Search.Administration.SearchServiceInstance

Have you ever seen this error in your ULS and wondered what it was?

SharePoint 2010 Event ID 6482 Application Server Administration job failed for service instance Microsoft.Office.Server.Search.Administration.SearchServiceInstance
I used to always ignore it because although it showed up once a minute in the logs SharePoint Search worked fine.


I got curious about it and decided to do some digging which lead me to this great article by Jeff DeVerter that explained what the issue was and how to resolve it.


And now thanks to Jeff, my ULS has been error free for 3 days!

Visual Studio build fails: unable to copy exe-file from obj\debug to bin\debug

My colleague fought this error for 2 days and finally found out what was causing this issue.


A little background is he was building a Console Application in Visual Studio to interact with SharePoint 2010.


He could rebuild this project many times over and work with it, debug it with no problems.


But, if he tried to run the .exe from windows explorer and then try to rebuild he would get the following error:
Error 4
Unable to copy file "obj\x64\Debug\Program.exe" to "bin\x64\Debug\Program.exe". 
Access to the path 'bin\x64\Debug\Program.exe' is denied.


After many failed attempts to narrow down the issue and trying many different solutions without avail finally he found a working solution.


It all has to do with a tiny little Windows Service called Application Experience.
The description of this service helps you understand why this service is important to what our issue is:
Processes application compatibility cache requests for applications as they are launched
Make its Startup Type Automatic and Start this service and you should be good to go.

Monday, July 16, 2012

SharePoint 2010: No Site Content Types Link

One of the most discuraging issues you will find when working with Content Types in SharePoint is a very simple issue. The Site Content Types link in the breadcrumb is not a link at all. Instead it is some grayed out text that irritates you every time you try an click on it.

So I got tired of trying to do this and thought I would take matters into my own hands.

Here is what I came up with:
function AddContentTypeLink() { 
   var spans = document.getElementsByTagName('h2'); 
   var stringToMatch = ' Site Content Types '; 
   for (var i = 0; i &lt; spans.length; ++i) { 
     if (spans[i].innerHTML.indexOf(stringToMatch) != -1) { 
       spans[i].innerHTML = spans[i].innerHTML.replace(stringToMatch ,"<a href='/_layouts/mngctype.aspx'>" + stringToMatch + "</a>"); 
       break;
     }
   }
 }
 _spBodyOnLoadFunctionNames.push('AddContentTypeLink');

Add this to an existing JavaScript file you have on the go (or in a CEWP on the settings pages where it exists if you are desperate)

If all worked properly you should be left with this:

It may not be pretty but it works well...

If you are working in a different language you can change the string variable to whatever it translates to (French for example is " Types de contenu de site " (don't forget the leading and trailing space!)