Showing posts with label SP2013. Show all posts
Showing posts with label SP2013. Show all posts

Tuesday, 9 September 2014

Surface 3 Pro as a web development machine




A few weeks ago I obtained a surface 3 pro (128gb/4gb), since then I have been using it constantly as my main machine in an effort to see if and how it can be used as a development machine, before this I was using a Lenovo Z500 (8GB ram, i7 3rd gen, 1tb disk) so I naturally compare the performance and use of the surface to that.

The work I do in a day to day basis:
  • PHP dev (LAMP server, VS 2013)
  • Powershell (ISE/prompt x 2)
  • ASP.net Dev (2-5 dev sites up at any time, all with VS 2013)
  • SharePoint Dev (SPD 2010/2013, VS 2010/2012/2013)
  • Graphic Design (Paint.Net, Photoshop)
  • Presentations and demoing (Office Suite, Lync, Camtasia)

So I main needs for a laptop are:
  • It needs to be Quick
  • Can handle the masses of chrome and IE tabs I have open along with a few instances of VS and a few RDP sessions
  • Portable (I generally carry it for atleast 2h/day)



The Good
  • The battery can generally see me through an entire workday without needing to charge, very useful for travelling
  • The plug has a USB charger built in
  • The build of the Surface is spot on, its solid and all the parts work well together
  • Size means its easy to use in smaller spaces
  • Nice in-built sound, for those spotify/netflix moments
  • Type keyboard feels good when typing, feeling like a miz beterrn a mac pro keyboard and the awesome old "tappy" keyboards
  • Its very portable, being list and small, the kick stand being able to pivot to most positions makes it great to have on most types of desk
  • The InstantGo functionality is nice, meaning you can just close the keyboard over the screen and the surface instantly goes into a sleep state, you can carry it around for hours and it wont loose almost any battery in that stage, great when you are about to make a demo or a presentation, one less thing the demo gods can smite you with! 
The Bad
  • The touch screen functionality in windows 8.1 still doesn’t really cut it when you need to use a lot of selecting so a mouse is needed
  • Use of display port means I have to carry a box of different cables around (VGA/HDMI/Ethernet) to connect to a wired network or to any external screen
  • 4GB of ram means occasionally being selective on the apps I have open and almost no possibility for on-box VM's, but with teh readily available Azure VM's, there isnt really a need to have the local VM's, atleast in the way we used to need them so this isnt much of an issue
  • Screensize can be a bit small, recommend docking it to a larger screen

Conclusion
I have found this to be a brilliant replacement for a the z500 laptop, it can rip through almost any work quickly, my biggest issue with it is the size of the screen, when developing on it, due to the nice resolution it means code can be hard to see, but of course if you have an office space, a doc and a 24inch monitor solves that very easily and cheaply.

Now i have been using this for weeks i cant see the need to go back to a full laptop unless you need that extra grunt for VM's or a few instances of Photoshop and other apps open

Ofcourse it depends on what you are looking for and the type of intensive web dev you do, based on my needs it ticked every box, i would use this for everything apart from local VM's

Wednesday, 25 June 2014

SharePoint 2010/2013: Enable-SPFeature Error (Failed to create receiver object from assembly)

So I had another lovely error recently, I had a wasp which had some external assemblies, I accidentally forgot to add one to the package manifest and when it deployed I got:

Enable-SPFeature : Failed to create receiver object from assembly "ASSEMBLYNAME, Version=1.0.0.0, Culture=neutral, PublicKeyToken=eaf1b7820cf1
fb30", class "CLASSNAME" for feature "FEATURENAME" (ID: 08284496-c68e-4f6c-befe-5777d14ad74b).
: System.ArgumentNullException: Value cannot be null.

So I instantly realised I was being silly and added the reference to the package manifest, packaged it, cabbed it, The Dll was in there, Great! I deployed the wsp and tried The deployment script again, it failed on the same point, I checked the gas, it was there alright, everything was looking as it should, but I couldn't activate the feature.

What was wrong? I tried deploying once more, did an observer for good measure and still nothing.

I then thought I would reopen the PowerShell window and try once again on the off chance that something was borked, so I restarted it, ran the script and it worked!

For some reason, the PowerShell session had cached the old error response from the feature activation, I don't know why but that's what it seemed to do.

Rule of thumb for the future, open a new ps session if you get an unexplained issue with a ps script

Tuesday, 17 June 2014

SharePoint 2013/365: Get current page properties/metadata with REST

Scenario

Retrieve the current page layout name via the page metadata on Office 365, this approach must be maintainable, flexible and not have any extra costs


Investigation

There are a number of ways to get the current page metadata with full trust code, simply using the SPContext.Current.ListItem allows you to get the collection, of course that wont work going forward with O365.

The most flexible way of working with any form of SharePoint object in O365 is to use JavaScript, thankfully there are a number of ways that can be done:

  • Use the JSOM - there are a number of blog posts currently on how to return the current items with JavaScript
  • Use Search - mapping properties and matching the search result by url is also a possibility, this is fast and allows easy optimisation
  • Use REST - there isn't much on this approach out there, it looks like a pretty obvious choice so i decided to try this approach.

Solution

The architectural approach is as such:
On Page Load

  1. Using the current context object data form a rest query
  2. Query the ListItem REST endpoint
  3. Get the page fields out of the returned data

Here is the finished codeblock:

Saturday, 15 June 2013

SP2013: Calling SP.ClientContext for an anonymous user causes "object doesnt support this method"

Good Morning!, and what a wonderful Saturday morning it is, the scent of strawberries are in the air!

So I've been working on a public facing 365 website lately and making a few customisations, one request I received was to have the ability for users to add an item to a "mailing list" list, and they wanted maximum portability, so I thought, perfect for the JS-CSOM!

Such a simple idea, add an item to a list, just needs one field adding in very straight forward, or so I thought, so I created the js function and hooked it up, for auth users it worked like a charm but I ran into a problem when accessing it anonymously, I got the error "object doesn't support this method" when calling a new "SP.ClientContext", its a straight forward error meaning it cant find the function in any loaded libraries, so I thought right, gotta be SP not loading sp.js, simple, add a script link in there... no luck the same error came up, then I thought right, gotta be that the method is running before SP.js is properly loaded so I used "ExecuteOrDelayUntilScriptLoaded()" to encapsulate my code and make sure it runs after the code is loaded, published the js and checked it again... no luck!

So it has to be sp.js not loading correctly, remembering the SoD SharePoint is so fond of I then tried the trusty "SP.SOD.executeFunc('sp.js', 'SP.ClientContext', addToMailingList)", and it worked perfectly!

Code:

$("#ben-mailinglist-confirm").click(function () {
    SP.SOD.executeFunc('sp.js', 'SP.ClientContext', addToMailingList)
});

function addToMailingList(metadata) {
    var metadata = $("#ben-mailinglist-email").val();
    if (metadata != "") {
        var clientContext = new SP.ClientContext("/");
        var list = clientContext.get_web().get_lists().getByTitle('MailingList');

        var itemCreateInfo = new SP.ListItemCreationInformation();
        var listItem = list.addItem(itemCreateInfo);
        listItem.set_item('Title', metadata);
        listItem.update();

        clientContext.load(listItem);
        clientContext.executeQueryAsync(
       Function.createDelegate(this, function () { $(".ben-mailinglist-success").show(); $(".ben-mailinglist-form").hide(); }),
       Function.createDelegate(this, function () { $(".ben-mailinglist-failure").show(); })
   );
    }
    else {
        // validation
    }
}