Inject Scripts in SharePoint with JavaScript

Mike BerrymanDon’t worry, it’s the good kind of Script Injection!

I was recently working in a SharePoint environment where I wanted to have some JavaScript libraries (like jQuery and moment.js) available across the entire site collection.  The most obvious solution would be to add a reference to each library into the master page(s) used across the sites in the site collection but for this situation editing any master page was not an option.  Instead I wanted to use User Custom Actions to do script injection.

Continue reading “Inject Scripts in SharePoint with JavaScript”

SharePoint File Extractor

Mike BerrymanDo not try and find SharePoint files, that’s impossible.  Instead, only try to realize the truth… there are no SharePoint files.

In SharePoint, most (not all) files don’t actually exist in the conventional way.  What I mean by this is that you can’t just browse to a directory and open a SharePoint page in your favorite text editor and make changes.  Instead, most files in SharePoint exist as BLOB data in a SQL database and the only way to actually edit these files is through SharePoint Designer.

So what if you want to have any of these files in source control?  Of course you could use SharePoint Designer to copy/paste the contents of each target file to your file system, but that is extremely cumbersome (you can’t just copy/paste a file itself, you need to actually open it and copy the contents).  As our clients have become more and more proficient with using SharePoint Designer to make their own changes we have had an increasing need to actually get these changes in source control.

Continue reading “SharePoint File Extractor”

SharePoint, Javascript Client Object Model and Correlation Ids

Mike BerrymanSharePoint has what’s known as the Client Object Model, which allows for code not located on the SharePoint server to access an object model of the SharePoint site.  One of the ways you can use this Client Object Model is by using Javascript.

Continue reading “SharePoint, Javascript Client Object Model and Correlation Ids”

SharePoint Client Object Model “Field does not exist” error

Mike BerrymanI was working with the SharePoint Client Object Model in Javascript a couple days ago and ran into the ever-so-common not-helpful error message of “Field does not exist” whenever any user other than myself would try and create a list item.  The weird part was, despite this error message, the list item was being created perfectly with no issues, with the field in question filled in exactly as entered on the form.  The only reason I knew there was an error was the fail callback function was being triggered, and consequently an alert box popping up with the “Field does not exist” error.

Continue reading “SharePoint Client Object Model “Field does not exist” error”

“The root of the certificate chain is not a trusted root authority”

Scott ZischerkI recently ran into an issue where a web service that I had set up through SharePoint was throwing the error: “The root of the certificate chain is not a trusted root authority”  The web service ultimately sent out an email with an attachment that is retrieved from a SharePoint document library.  The error was occurring when I created a HttpWebRequest and called the GetResponse method.  Initially, I tried to reassign the ServicePointManager.ServerCertificateValidationCallback property to a method that just returns true, but that didn’t seem to work.

Eventually, I found this blog post: http://godwinsblog.cdtech.in/2010/12/sharepoint-2010-root-of-certificate.html that had me download all the certificates in the SSL certificate chain and add them into SharePoint.  After adding the root, intermediate and SSL certificate the web service started working properly.

SharePoint’s Data Form Web Part, Edit Mode, and “Id” Query Parameter

Mike BerrymanSo a few days ago, I stumbled upon a baffling bug in SharePoint while using a data form web part to allow for editing a list item in a custom list.  In the past, whenever I’ve created custom data form web part pages for editing, I’ve always followed SharePoint’s schema of using the “Id” query parameter to indicate which list item is being editted.  In this case, I was already using “Id” in another web part on the same page, so I just modified my data form web part to use some other query parameter, like “ItemId”.  Simple, right?

Continue reading “SharePoint’s Data Form Web Part, Edit Mode, and “Id” Query Parameter”

Configure Windows Live Writer 2012 to work with SharePoint 2010

2_bgI use Windows Live Writer( for no other reason than it is simple and works) to create blog posts.  I am running Windows 8 and downloaded Live Writer 2012. I then began the seemingly simple steps to configure it to publish directly to SharePoint. First, I started Live Writer and followed the steps in the wizard and received an error stating: “Problem with blog server – server error 2041 occurred. Attempted to perform an unauthorized operation.” Here are the steps to reproduce the error.

Continue reading “Configure Windows Live Writer 2012 to work with SharePoint 2010”