Thursday 31 October 2013

SharePoint 2010 Set - Overwrite existing files checkbox - to default to unchecked

Uncheck the Overwrite existing files when uploading a new document


If you would prefer users not to overwrite existing files by default when they upload new documents in SharePoint try adding the javascript below to the bottom of your System master page file just above the PlaceHolderFormDigest control.


<script type="text/javascript">
  document.getElementById("ctl00_PlaceHolderMain_UploadDocumentSection_ctl03_OverwriteSingle").checked = false;
 </script>


Simple but effective - Let me know if this helps you!!

SharePoint Lookup Column - Dropown list spacing and positioning

SharePoint 2010 Dropown list from Lookup column appears in the wrong place!!


Experiencing some strange behaviour when selecting options from a drop down list from a lookup column while developing a SharePoint 2010 application, I immediately thought that I had developed some erroneous styles in my css.

Upon further investigation and testing with no custom style sheets using only the out of the box V4 master page and core css I quickly realised that this is a SharePoint "Feature" (bug)!



Selecting the lookup drop down list with more than 20 items

A quick search to see if I could find an elegant solution to my problem and all of the recommendations that I found in blogs, forums and articles involved developing code to override the 20 items or more rendering of the drop down list select box to use the standard drop down list.

I didn't think that was good enough and so I decided to carry out some problem solving of my own, after about 10 minutes of tinkering with IE developer tools and my stylesheet I came up with a very neat and tidy 2 line CSS fix.

Microsoft - Why haven't you though of this??

Solution

Add the following styles to a custom style sheet referenced by your site!

select
{
    position: inherit !important;
    display: block;
}


more than 20 lookup items looking good!
 
If you have any comments please let me know, thanks for checking out Planet SharePoint blog!!
 
 


Friday 25 October 2013

Content Query Web Part Key cannot be null

Content Query Web Part Key cannot be null


ArgumentNullException: Key cannot be null.
Parameter name: key

Very useful error message!!!! There is a conflict with the Developer Feature in SharePoint 2013 which appears to break the content query web part. Not so hot if you are relying on using this web part on your development site where you need the development feature to be available.

To resolve this issue you will need to disable the feature, unfortunately it is a hidden feature so you will need to disable this via SharePoint 2013 management shell. The powershell script below should help, run this, it will disable the SharePoint 2013 developer feature and Viola you have a working Content Query web part.

------- Start disable developer feature command -------------

Disable-SPFeature -identity  "E374875E-06B6-11E0-B0FA-57F5DFD72085" -URL http://yoursiteurl

------- Endable developer feature command -------------

Once you have configured your content query web part you can re-enable the developer feature if required using the script below.

------- Start enable developer feature command -------------

enable-SPFeature -identity "E374875E-06B6-11E0-B0FA-57F5DFD72085" -URL http://yoursiteurl

------- End enable developer feature command -------------

Hopefully we will see a fix in the next Cumulative update for this issue, I'm sure there will be more. About time for a Friday night SharePINT

Master Page inheritance breaks Apps

Master Page inheritance breaks Apps


Setting the Master page and selecting "Reset all sub sites to inherit this site master page setting" will break all of your Apps!!!!








Error:
Accessing referenced file http://xxxxxxxxxxxxxxxxxx/_catalogs/masterpage/mymaster.master from http://xxxxxxxxxxxxxxxxxx/myapp................ is not allowed because the reference is outside of the App Web.

Exception Details: Microsoft.SharePoint.WebPartPages.WebPartPageUserException: Accessing referenced file <Master Page URL> from <App URL> is not allowed because the reference is outside of the App Web.

Cause
If you have developed custom apps or have purchased apps from the App store and are using these on your SharePoint sites beware of using the "Reset all subsites to inherit this site master page setting" when setting the master page of your sites or if you have set the master page via deploying the . Stand alone apps need to inherit the App.master page.

Immediate Fix #1
Use this powershell script to set the App master page of your app.

Create a new file named setappmaster.ps1 in notepad and add the script below (OR YOU CAN DOWNLOAD THE POWERSHELL SCRIPT FILE FROM CODEPLEX)

https://setappmaster.codeplex.com/

Write-Host "----------Start of set app master page --------------"

$appsiteurl = $args[0]
$appweburl = $args[1]
try
{
$appsite = Get-SPSite $appsiteurl
$appweb = $appsite.OpenWeb($appweburl);
$appweb.CustomMasterUrl = "/" + $appweburl + "/_catalogs/masterpage/app.master"
$appweb.MasterUrl = "/" + $appweburl + "/_catalogs/masterpage/app.master"
$appweb.Update()
}
catch
{
Write-Host 'Error setting app.master'
}

Write-Host "----------End of set app master page --------------"

Run the new setappmaster.ps1 file in SharePoint 2013 Management Shell using the command below replacing the App Site and App Web URLs in bold with your own URLs

c:\powershell\setappmaster.ps1 'http://app-b77adfc321c0f.apps.com:9090/' 'MyApp'


Immediate Fix #2
Redeploy your apps to reset the master page back to App.master

Solution #1
You could use code and feature stapling to set your master page via the SharePoint API instead of using the standard Master Page Settings page, iterate through all sites and set the master page of each using an exception to check for isAppWeb and ignoring sites that are app webs.

Solution #2
When developing your custom apps change the master page url on all of the stand alone App pages to a fixed URL pointing to the App.master. This will cause problems if you plan on redistributing the app.

-------------------

If you have any comments or questions please give me a shout!

Friday 4 October 2013

Office 365 SharePoint Online Vs On-premises

Microsoft's are ramping up their push towards their cloud offerings with Office 365. Specifically with SharePoint online the Features and services along with the new App Model to deliver a more customisable solution have really closed the gap on what you can produce in an on-premises solution.

One big downfall with SharePoint Online that I have noticed and would love to see available in the future is the ability to add Site Definitions in your custom solutions. Without the ability to add your own site definitions SharePoint Online really is limiting how we can produce tailored solutions to the market, I would love to be able to create a new Team site definition or a new Project site definition that aligned itself to my customers needs without them having to tinker with the configuration of every new site that they create. Along with this feature stapling would be another great benefit to allow the application of design elements, activation of custom solutions etc from any newly created site. If anyone has a cool workaround for these in SharePoint Online send me your comments!

The links below are useful as a reference to identify what limitations there are for SharePoint in the cloud.

SharePoint Online and On-premises comparison of Service descriptions (Navigation links to a breakdown of roles and services)

SharePoint Online and On-premises comparison of Developer features

 
If you haven't already seen whats new for developers in SharePoint 2013 check out the link below to see what's on new for you to do!

New SharePoint 2013 on premise developer features


My next post will be available shortly where I'll give you an update on how my study for SharePoint 2013 and Office 365 exams is coming along and hopefully give you a few pointers on what material is out there to help you if you're thinking about SharePoint 2013 certification.

Friday 16 November 2012

In The Beginning

So.... I finally got round to posting my first blog on a site that I created 5 years ago! My intention is to keep this blog up to date with my dealings in SharePoint, providing my readers (You!) with some of my more challenging tasks and encounters. Hopefully you will find it informative, possibly helpful and on the odd occasion inspiring and entertaining.

When I have the spare time I will post tutorials, code, insights and examples of how to and how not to deliver on certain aspects of your SharePoint (This blog won't be explicitly SharePoint orientated) delivery requirements. Delving into past projects I hope to post a backlog of entries detailing experience, tips and tricks learned over the last 11 years of development.

I hope you find it insightful!