Category Archives: SharePoint 2013

JS Link – CSR View Conditional Formatting

This post builds on the JS Link – CSR Simple View Field Formatting post.

If you can format a single field as was done in the previous example, it’s not a big step from there to using conditional formatting.

In SharePoint Designer (pre-2013) one of relatively easy yet powerful features  was conditional formatting – the ability to dynamically change how content was displayed based on rules. In the last post we went over how to do simple formatting, in this post we’ll review how to incorporate some simple rules or conditions.

In the previous example we bolded everything in the Issue Status field.

image

In this example we’ll ‘conditionally’ select which items are bolded based on data values for each item.

image

We’ll start with a couple of individual fields and go from there. For this example and similar to the last post, I created a page in the Site Pages library and added the Office Issues web part to the page. I’ll be setting the JS Link property of the web part here in a few steps.

In this post we’re adding three concepts:

  1. JavaScript – Calling a function.
    If you are a JavaScript developer this concept isn’t really even worth mentioning. If you are not a developer, we’re moving the code around a little bit to keep it organized, easier to read, etc…image‘Status’:{‘View’: ConditionalStatus},
    In this line rather than setting the value of the field outright like we did with simple field formatting, we’re calling a function ‘ConditionalStatus’ where addition work is being done.
  2. Checking for the ‘condition’ or rule.
    imageWithout getting into all the JavaScript details, what we’re doing in the function is checking the value of the ‘Issue Status’ field and either making the contents bold, or leaving them in the default format.if (ctx.CurrentItem.Status == “Active” ) {
  3. Building the HTML for what is displayed or rendered in the web part on the page.In this example we’re just using a the HTML tags necessary to bold the content being displayed. You could use virtually any HTML or CSS you wanted when it comes to formatting the data:ret = “<b>” + ctx.CurrentItem.Status + “</b>”;

    You should also note the way we set up the data. The HTML and field data need to be built into a string – which is different than the way we did it in the previous post.

The full sample code can be found HERE.

The completed file is then uploaded to your chosen location: Master Page Gallery in this case. The web part JS Link property is configured to point to your JavaScript file:

~site/_catalogs/masterpage/[yourFileName].js

Notes:

    • You are not limited to pairing the conditional field with the field that is custom rendered.
      If Issue Status is ‘Active’, bold the Status field…
      You can just as easily define a rule for the Title field to check the value of the Issue Status field.
      If the Issue Status field is ‘Active’, bold the Title field…
      You can also combine rules into more complicated criteria
      If Issue Status is ‘Active’ and Priority is ‘High’, then bold the Title field…
  • Rather than customizing how each field is displayed separately, you can use a different override – the Item override – to customize each field or how the entire item is displayed. This will be covered in a separate post.

JS Link – CSR Simple View Field Formatting

One function that SharePoint Designer (pre-2013) was great for was doing some quick formatting changes to views – tweaks not available through normal view configuration. This example shows how you can implement simple changes to the field formatting using SharePoint 2013’s new JS Link property and Client-Side Rendering (CSR) – though some simple JavaScript.

Looking at an Issues app (list), we’ve got a ‘Issue Status’ field that we’d like to show as bold. Here’s how it looks in it’s native default view:

image

In order to override how a field is displayed (or ‘rendered’ – the ‘R’ in ‘CSR’) you need to create a JavaScript file that defines the Field Override we’re using. The full contents are shown here:

image

Much of this code is boilerplate. The key line in this is:
’Status’:{‘View’: ‘<b><#=ctx.CurrentItem.Status#></b>’}

and it breaks down like this:

  • ’Status’:{‘View’: ‘<b><#=ctx.CurrentItem.Status#></b>’}
    ’Status’ is the column in the view being overridden.
  • ’Status’:{‘View’: ‘<b><#=ctx.CurrentItem.Status#></b>’}
    ’View’ is the type of page
  • ’Status’:{‘View’: ‘<b><#=ctx.CurrentItem.Status#></b>’}
    This is the HTML string that is constructed to replace the current contents of the column. The ctx.CurrentItem.[InternalFieldName] is referring to the column value of the item. This is where things can get as complicated as you want to make them by building more complex strings, combining field values much like a calculated field but using JavaScript instead of the Calculated Field type.

As mentioned in my other posts, you need to use the internal field name when referencing it in the code. You can find this in a number of ways but the easiest for me is to look at the list settings and click on the field name you’re looking at. The URL will show the internal name in the string (example shown below). With this particular example we can see in the Columns listing that the field is referred to as ‘Issue Status’, but that the internal name is actually ‘Status’.

https://yourdomain.com/sites/CSR/_layouts/15/FldEdit.aspx?List…&Field=Status

Upload the JavaScript file to the Master Page Gallery (yes, you can use alternate locations…).

For this example, I created a page in my Site Pages app (library) and added an App Part to the page for the ‘Office Issues’ app that I had created. I left the web part using the default view (shown above).

Note: Technically, you can edit the web part on the actual view page, but I don’t generally like to do that unless there is a really good use-case for it. It can be confusing to users and administrators.

On the page that was created, edit the page and edit the web part. At the far bottom of the web part properties is the JS Link property. Put your file name in the field and click ‘OK’.

~site/_catalogs/masterpage/[yourFileName].js

As soon as you hit ‘OK’, if all the parts are connected your override should be in place and the view should change to reflect your change.

image

Notes to remember:

  • You aren’t changing the view itself. If you go to the list and look at the view, it will not reflect your CSR. Only the page where you are applying the CSR will show your changes.
  • If you want to override more than one field, the code looks like the following:
    image

If you’d like to walk through a simple ‘Hello World’ example to make sure your file is in the right place and your JS Link property is properly set take a look at the following posts:

JS Link – Hello World

JS Link and CSR (Client-Side Rendering) for SharePoint 2013 are often used interchangeably, but they aren’t exactly. The JS Link web part property is a way to add CSR template overrides to your page.

This quick post walks through a ‘Hello World’ scenario that doesn’t do any CSR, but makes sure your JavaScript file is working and that the JS Link reference can find it.

I’ve got a longer post on more of the details and use of JS Link for CSR in SharePoint 2013, but this is a quick ‘Hello World’ version for JS Link. There are three main components:

  1. Create a JavaScript file
    This file, saved as [yourFileName.js] literally only needs to have a single line:
       alert(“Hello World”);
  2. Put the file in a location where your JS Link reference can see it.
    • One common location to upload to is the Master Page Gallery though other locations can be used. This does require higher permissions on the site, however.
    • Using this ‘Hello World’ approach is a great way to test the location of your file, the permissions to that file and the JS Link string (next step) used to get everything working.
    • If you are a site collection administrator you can use SharePoint Designer 2013 to view ‘All Files’ in the Master Page Gallery and add a new JavaScript file that way.
  3. Point your web part to the JavaScript file.
    You are changing the properties of a web part here. Technically you can edit the web part of a standard view for a list, but I generally don’t do that.
    1. For this example create a page on the site and drop a web part from your test app (list or library) on to that page.
    2. Edit the page and Edit Web Part. At the far bottom of the web part properties, under the Miscellaneous grouping is the ‘JS Link’ property.
    3. Enter the following and click OK.
      ~site/_catalogs/masterpage/[yourFileName].js
  4. If everything is working as planned, as soon as you click ‘OK’ you should get a JavaScript alert that says ‘Hello World’.

Now, you can start playing with CSR or other functionality with the JS Link. Check out my Primer post… more examples are coming shortly. Smile

SharePoint Fest Chicago

I’ve got two sessions this week at SharePoint Fest Chicago.

PWR104 – Build a SharePoint Intake / Request List

PWR202 – Customizing Sites and Pages in SharePoint 2013

Slide decks for both will be up shortly. I need to make a few tweaks and updates to capture a few missing screenshots that were missing. Thank you for your patience.

SharePoint Fest DC – PWR104 – Customizing SharePoint 2013 Sites and Pages

The following is a link to the slides from today’s session on (mostly) CSR and JSLink within SharePoint 2013.

Much of the CSR / JSLink content and instruction can also be found in the blog post found here:
http://www.idubbs.com/blog/2012/js-link-for-sharepoint-2013-web-partsa-quick-functional-primer/

Other recent posts worth checking out:

SharePoint Saturday Twin Cities–May 2013

Another great event this past weekend – for those of us that were able to navigate the monsoon in the morning. Almost 500 attendees made it in.

Slide decks should be posted to the www.spstc.com soon. Until then I posted mine out on Slideshare if anyone wants to take a peek at them.

SharePoint 101: What is this thing called ‘SharePoint’?
This is a really high level overview of what SharePoint is and what it offers to an organization…

Understanding SharePoint Roles
This is an overview of all the different roles and responsibilities that can play a part in a SharePoint implementation… lots of discussion during the session…

Use SkyDrive Pro with a Office 365 2010 account

I want to keep my stuff in SharePoint, but also have it synched down to a local location. Should be cake with SkyDrive Pro, but my 365 account hasn’t been upgraded yet. So, what to do… Well, it turns out as long as you have the SkyDrive Pro app installed, you can still do it with your 2010 ‘era’ site.

UPDATE: SkyDrive Pro client is now (5/22/13) available for download for Windows. More info can be found HERE.

  1. Create an account on the NEW Office365 – the latest ‘2013’ version. At the present time existing accounts are being upgraded while new accounts are all on 2013. What we’re doing  can be one of the free demo accounts – we just want to get the SkyDrive Pro client installed.
  2. Create a user account and have the user log in to the account.
  3. In the top navigation bar towards the right side, click on the ‘SkyDrive’ link. If this is a new account, you might need to do some basic configuration steps – it’s creating a My Site for you, etc.
    image
  4. Just below the top navigation bar and further to the right, click on the ‘Sync’ button and follow through a few dialogue boxes.

As I understand it, configuring your first library to sync locally will get the app installed and working locally. By default, the initial Sync action uses your My Site document library as the default library to configure – the “Share with Everyone” library. Once this is set up, you should have a synched folder that shows up in your Favorites in File Explorer called ‘SkyDrive Pro’. You can remove this sync folder later.

Now that you’ve got the app installed, let’s go ahead and add a 2010 library to be synched.

In your Windows tray, you’ve now got a SkyDrive Pro icon (the blue one) – you may also have a ‘normal’ white SkyDrive icon as well…
image

  1. Right-click on the SkyDrive Pro icon and select ‘Sync a new library’
    image
  2. Paste your 2010 version 365 document library URL in there… it’ll now create a ‘SharePoint’ folder in addition to the ‘SkyDrive Pro’ folder and sync your 2010 library in there.
    image

Good to go!

I don’t know if there’s a way to get the SkyDrive Pro install without doing this, but this process does work.  Smile

Oh, and here is an article from a MS blog on it as well: http://office.microsoft.com/en-us/support/sync-a-library-to-your-computer-HA102832401.aspx?CTT=5&origin=HA102822076

Registration is open for the Spring 2013 SharePoint Saturday Twin Cities

SharePoint Saturday Twin Cites will have its Spring event on May 18th, 2013. We will again be at the Normandale Community College campus, but this time will be using the brand spanking new wing and rooms (still using the same entrance area on the West side).

Registration: http://spstcspring2013.eventbrite.com/

The last few events have filled up – so get signed up early. Also please be courteous to other hopeful attendees and cancel your registration if you are unable to join us.

We’ve got one of the largest SharePoint Saturday events in the country and with feedback from attendees, speakers and sponsors, one of the most successful as well. So join us for another day of SharePoint with tracks for SharePoint 101, Information Workers, Developers, IT Pros and a new vendor showcase room – all for free.

We have a new web site on the way as well. Keep an eye on http://www.spstc.com for information on sponsors, speakers, sessions and schedules coming soon. Also ‘Like’ our Facebook page for more immediate updates.  https://www.facebook.com/SPSTwinCities

We look forward to seeing you there!

Group Work Site, Feature and Lists: 2010 to 2013

The short answer/story is that they are deprecated – no longer available… The reason given was that they were not widely used. The Group Work  site is not available when selecting sites in 2013 and the site feature is no longer available to be enabled.

The template ID does still show up in the 15 hive – to accommodate migrations from 2010. However, the article listed below also states that these templates and features will NOT be available in a future ‘major’ release.

The official notice can be found here from Microsoft:
http://technet.microsoft.com/en-us/library/30d640e8-bb5d-4547-b28a-94cc8bbf0dbe(v=office.15) 

So, where does that leave us if we DO want to use these features?

Group calendar and Resource Reservation
For the Group Calendar and Resource Reservation features added to the traditional calendar, the better long term replacement is using Outlook/Exchange. Ideally, the people being scheduled would be in Exchange as users anyhow so they could get the benefit of alerts, personalization, etc. It is unfortunate that this does go away however for some small businesses that with the feature could do without additional licensing. However much more capability comes with having ‘real’ accounts.

‘What’s New’ Web Part
First of all – Laura does a wonderful job of giving a detailed look at this web part here: http://www.sharepoint911.com/blogs/laura/Lists/Posts/Post.aspx?ID=92 

The properties of this web part have made the filtering much easier for users. However the same capabilities do exist with normal date, item number and column filtering. What this web part does that others don’t is include content from multiple lists – which is really nice. Now, you can still use separate web parts to accomplish this, but its not as nicely wrapped up as this web part does. 

Circulation List
Much of this functionality can be replicated by using workflows on a document library list. But it was nice to have it pre-baked and wrapped up nicely to use without the additional work.

Phone Call Memo
Much of this one can be replicated fairly easily using a custom list, views and SharePoint Designer workflows. But, as many have commented much of this also goes away with all the social tools and other capabilities we have available to us these days with automated phone systems, etc.

Whereabouts List
Again, much of this functionality is available via Exchange/Outlook or other communication tools. A SharePoint list/calendar can certainly be used for this when all the parties are not in the system and accomplish much of the same thing, without the nice interface that this list and web part provided.

One thing I have not yet tried is exporting web parts from a 2010 farm and importing them into a 2013 farm to see if that works. HOWEVER, I would recommend finding better – supported – solutions to doing this so that you’ve got a solution that will be supported going forward rather than just finding a way to extend a capability that we know is going away. (just in case you were wondering or thinking about that option…)

At the end of the day, this feature set was a nice group of pre-baked mini solutions that were handy in certain circumstances – most of the scenarios were for small business users that didn’t have some of the tools available through Exchange, etc. Now, with the availability of Office 365 for organizations of all sizes, these capabilities (and much more) are available through those licenses – though getting the specific solutions takes a little more stitching together to get.