Microsoft cloud engineer - SharePoint, Office 365, Azure, DotNet, Angular, JavaScript.
Microsoft cloud engineer - SharePoint, Office 365, Azure, DotNet, Angular, JavaScript.

May 2014

Quick Edit supports JS Link and Client Side Rendering

Today I attended #SPSChicagoBurbs and the session by Wes Preston (@idubbs)  on Client Side Rendering.   A question was asked by someone in the audience if Quick Edit (new Data Sheet) would support CSR rendering.   The consensus was probably not because of the advanced rendering, event handlers, and cell editing.

 

I gave it a quick test and surprisingly it worked!  

Smile

 

 

When I renamed a file to become “test.txt” it turns the background green, text white, and even shows a custom icon <IMG> tag.   This could be leveraged to give end users real-time feedback on the values entered.   Unlike a JQuery page load event which only triggers once, this triggers per row as values are changed.

 

Video

csr-quick

 

Screenshot

5-17-2014 12-35-08 PM

 

Code

//override
(function () {
    var overrideCtx = {};
    overrideCtx.Templates = {};
    overrideCtx.Templates.Fields = {
        'LinkFilename': { 'View': ConditionalStatus }
    };
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();
function ConditionalStatus(ctx) {
    var ret;
    console.log(ctx.CurrentItem.FileLeafRef);
    if (ctx.CurrentItem.FileLeafRef== "test.txt") {
        ret = "
" + "
" + ctx.CurrentItem.FileLeafRef + "
"; } else { ret = ctx.CurrentItem.FileLeafRef; } return ret; }

Get Design View back on SharePoint 2013 (woohoo!)

Want to use Design View on a 2013 site?  Well, now you can.

With a Fiddler HTTP function we can adjust the server response to say “14” instead of “15” and open any SharePoint 2013 site with SharePoint Designer 2010 to have access to classic Design View.   Obviously there are downsides to this approach (not formally supported), but it also can be useful in many scenarios.  Check it out and please leave a comment if you find this helpful.

 

Instructions

  1. Download Fiddler http://www.telerik.com/fiddler
  2. Download SP Designer 2010 http://www.microsoft.com/en-us/download/details.aspx?id=16573
  3. Launch Fiddler, press Ctrl + R, and update the Custom Rules JS file with the code below
  4. Launch SP Designer 2010 and open site URL
  5. Have fun!

Fiddler

You need to add Custom Rules to Fiddler.  There are two options:

  1. Download CustomRules.JS with custom logic
  2. Copy the below code and add to your local CustomRules.JS file in the function OnBeforeResponse(oSession: Session).

// START BLOG POST from @spjeff 
// https://www.spjeff.com/2014/05/08/get-design-view-back-on-sharepoint-2013-woohoo
//INF
if (oSession.oRequest["User-Agent"] == "Mozilla/4.0 (compatible; MS FrontPage 14.0)" &&
	oSession.PathAndQuery == "/_vti_inf.html") {
	// Remove any compression or chunking
    oSession.utilDecodeResponse();
    if (oSession.responseBodyBytes) {
        var oBody = System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes);
    
        // Replace strings
        oBody = oBody.replace("FPVersion=\"15.00.0.000\"", "FPVersion=\"14.00.0.000\"");
        oSession.utilSetResponseBody(oBody); 
    }
}
//RPC
if (oSession.oRequest["User-Agent"] == "MSFrontPage/14.0" &&
	oSession.PathAndQuery == "/_vti_bin/shtml.dll/_vti_rpc") {
	// Remove any compression or chunking
    oSession.utilDecodeResponse();
    if (oSession.responseBodyBytes) {
        var oBody = System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes);
    
        // Replace strings
        oBody = oBody.replace("major ver=15", "major ver=14");
        oSession.utilSetResponseBody(oBody); 
    }
}
 
//AUTHOR
var suffix = "/_vti_bin/_vti_aut/author.dll";
if (oSession.oRequest["User-Agent"] == "MSFrontPage/14.0" &&
	oSession.PathAndQuery.indexOf(suffix, oSession.PathAndQuery.length - suffix.length) !== -1) {
    if (oSession.responseBodyBytes) {
        // Remove any compression or chunking
        oSession.utilDecodeResponse();
        var oBody = System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes);
    
        // Replace strings
        oBody = oBody.replace("
  • SR|15.0", "
  • SR|14.0"); oSession.utilSetResponseBody(oBody); } } // END BLOG POST
  •  

    Use Cases

    • Support upgraded 2010 sites.    If you developed with SP Designer 2010, you might need Design View to support sites after upgrade to 2013.
    • New HTML and CSS creation.  WYSIWYG can be great for making simple files to support new JavaScript development.
    • DataFormWebPart .  Create blank ASPX page, add the DataFormWebPart and Conditional Formatting with WYSIWYG, then copy finished <DataFormWebPart> code tag into a 2013 native ASPX page.

    Notes

    • Non intrusive approach.   Fiddler runs local on the developer’s machine.   No server changes or changes for end users.
    • This doesn’t give you Design View of any native 2013 ASPX page.  Those are fundamentally different with new Minimal Download Strategy async load, new master page, and other stuff so it just shows a gray background.
    • Not formally supported.
    • Cool way to support SP2010 upgraded sites.

    References

     

    homer-computer-woohoo

     

    5-8-2014 3-41-29 PM

    SPLaunch – new CodePlex for PowerShell automation

    Yesterday I published a new CodePlex project to automate PowerShell remoting.   Basically I got tired of RDP-ing to 10 machines to type the same command 10 times.  Why not use a local PowerShell window to read CSV with server names and execute remotely in bulk?    Well, now you can.

     

    Give it a try for an hour to download, setup, and run.  You can save that much time in just a day by using this in instead of juggling RDP and typing multiple PowerShell commands.   Please leave a comment or CodePlex review to let me know what you think.  

    Smile

     

    http://splaunch.codeplex.com/

     

     

    Business Challenge

    • Growing list of servers
    • Inconsistent configuration (DEV has, TEST lacks, PROD just crazy)
    • Need to reduce admin time. Make room for business analysis, teach how to use, evangelize features

    Technical Solution

    • PowerShell remoting + automation wrapper = rapid fire commands
    • PS1 with functions
    • Noun CSV with server farms and login user
    • Verb CSV with "shortcut" alias PowerShell commands
    • Mix and match Noun/Verb CSV with automation wrapper (New-PSSession / Invoke-Command)

    Examples

    Open all servers in the "DCO" farm (Development Collaboration) and show total RAM size with percent used:

    • LaunchFarm DCO
    • LaunchShortcut ram | ft -a

    Open just the first server across all farms and show the SharePoint build number:

    • LaunchFarm ALL 1
    • LaunchShortcut spver | ft -a

    NOTE – MUST MANUALLY UPDATE "Noun" CSV file with target machine names, AD domain,
    and user account before any commands can be run.

     

    Screenshots

    1

    2

    3

    4

    Getting Started

    • Enable PowerShell remoting and WSMan CredSSP on all target servers. "Enable-PSRemoting -Force"and "Enable-WSManCredSSP -Role Server" http://dustinhatch.tumblr.com/post/24589312635/enable-powershell-remoting-with-credssp-using-group
    • Enable PowerShell client with "Enable-PSRemoting -Force" and "Set-Item wsman:\localhost\client\trustedhosts * -Force"
    • Update NounCSV with servers and user names
    • Run "SPLaunch.ps1 -install" to add to $profile so it starts with new PowerShell windows
    • Run LaunchAFarm to see farms
    • Run LaunchAFarm DCO to connect to that farm (comma separated allows multiple farms)
    • Run LaunchAShortcut to see shortcuts
    • Run LaunchAShortcut RAM to execute the "RAM" command (end with " | ft" to format as table)
    • Enjoy!

    Warnings

    • Account lockout – Possible if typing the password wrong and open many sessions at once.
    • System update – Verb CSV can modify configuration on many servers quickly. Use carefully for changes.

    Please drop me a line via email spjeff@spjeff.com or Twitter @spjeff with ideas. I’m always open to suggestions and improvements.

    WordPress Security Scan

    Today I found http://hackertarget.com/wordpress-security-scan/ and ran a scan of this website.  Nothing major was discovered, but a few improvements to harden and make the system more secure.  If you have WordPress you might want to run this also.  Great way to get simple suggestions for tighter security:

    • Update WordPress version 3.9
    • Update all plug-ins
    • Disable any plug-ins you don’t use
    • Disable directory browsing
    • Rename admin user

    To learn more about WordPress security take a look at http://www.hongkiat.com/blog/hardening-wordpress-security/

     

     

    5-1-2014 1-31-24 PM

    © Copyright 2016
    @ SPJeff

    Return to Top ▲Return to Top ▲