Sharepoint: Change Sort Order Within A Group In A Grouped View

Sharepoint’s built in grouped view is a quick, useful way to make long lists more user friendly. It allows you to group items together based on a common value in a field and provides a “toggle” option to open or collapse each group. But once you’ve added the grouped view, you may find sorting your list is not as straightforward as you’d expect.

Adding a custom sort option to the groups (to manually control the order in which they appear) is simple enough. You can add a “sort” field – so non technical users can simply enter a number to determine the order. But what if you also want to sort items WITHIN EACH GROUP? You would think you’d just add a second sort option – so:

  • First sort by your group sort field
  • Then sort by your sort within a group field

But if you do that, the second, “sort within a group” option is ignored. When it didn’t work for me, I quickly googled for “sort within a group when using a SP  grouped view” but got no useful results. So I tried reversing the sort options – in other words, first sort by the Sort Within Group field, and THEN by the Group Order field….and even though this seemed highly illogical to me, it worked.

So once again, Sharepoint provides a useful feature made less useful by the unintuitive interface. Anyway, that’s how to sort the sorts when using a grouped view!

This should work for all versions of Sharepoint, but I’ve only tested it in Sharepoint Online.

Add a clickable, “friendly” title to your Sharepoint Online 2013 documents – AND open them in the browser!

17_6_21_weird_file_names_revision_3.docx -SAY WHAT??

Let’s face it, file names are often not pretty. The underscores, hyphens  and other meta data elements in company naming conventions along with individual quirks and naming habits, can lead to some pretty unfriendly looking links in your document libraries.  You’d think the creators of Office would know better, but Microsoft doesn’t provide a simple way to replace those odd looking links with more descriptive text that would help end users find the files they need.

Rendering html in a calculated field – RIP 6/13/17

The easiest solution was always to use the trusty calculated field to replace the file name with something else that humans might understand. But since Microsoft announced on June 13th they removed the ability to render calculated fields as html (on June 13th  – supposedly to terminate this 10 year old “security risk”  – nice!) – come September (if you got the extension) this will no longer be an option.

Jslink saves the day

Fortunately for now at least, we have jslink – which allows you to rewrite how a web part is rendered. You can google up many expert tutorials on how to use jslink – I’m just concerned here with the specific syntax needed to replace a file name with user friendly text.

To start, add a single line text field to your library to contain the text you want to use, naming it something really original, for example: “Title”.  Overwrite the “Item” ctx element with the following:

overrideCtx.Templates.Item = CustomItem;
function CustomItem(ctx) {
// Build a list item entry for every item in the list.
var ret = “<div class=’link’><a href='<domain/library>” + ctx.CurrentItem.FileLeafRef + “‘>” + ctx.CurrentItem.Title +  “</a> </div>”;
return ret;
}

In this example, “ctx.CurrentItem.FileLeafRef” provides the file name and “ctx.CurrentItem.Title” provides your user friendly title.

Add “open in browser” functionality

The only issue with this approach is it will force users to download the file, and won’t open it in the browser, regardless of the settings you’ve configured for the library (another piece of Microsoft brilliance!)

If you want users to be able to open files in the browser, you’ll need to include one of the url query parameters that enforce that behavior in your script. I found this link format works best:

<domain/library>/_layouts/15/WopiFrame.aspx?sourcedoc=%7B<item guid here>

To derive the internal field name for the item guid, I turned to this handy list of internal field names and found it was “UniqueId”.

So now to display a user friendly file name AND open files in the browser, update the jslink script to:

overrideCtx.Templates.Item = CustomItem;
function CustomItem(ctx) {
// Build a list item entry for every item in the list.
var ret = “<div class=’link’><a href='<domain/library>/_layouts/15/WopiFrame.aspx?sourcedoc=” + ctx.CurrentItem.UniqueId + “‘>” + ctx.CurrentItem.Title + “</a> </div>”;
return ret;
}

 

More fields, no problem

Follow the same syntax above to add any number of other fields to your list view – just make sure they’re included in the view you’re using. And that’s how you turn “17_6_21_weird_file_names_revision_3.docxinto “Weird File Names June 2017”

 

 

 

Create a custom view and rss feed of a Sharepoint Online 2013 survey

A unique feature of the “survey” app in Sharepoint Online is the built in branching logic which makes it a useful choice for questionnaires etc. But if you want to customize the results view that users can see, you’ll find that Microsoft, in their infinite wisdom, has intentionally hidden the standard “create a view” option in the survey (aka list) settings.

The create view url

Fortunately, it’s only “hidden” and can easily be accessed if you know the correct url. To find that url, open up a regular list, click the “list” tab and “list settings” in the ribbon, and the “create view” link. The url format is:

https://<domain>/_layouts/15/ViewType.aspx?List=%7GUID%7D&Source=URL TO REDIRECT TO

So the magic page address is “ViewType.aspx” and if you combine that with your survey’s GUID , you can create your own views.

To do that, navigate to “site contents” and click the tile for your survey. Under the “settings” link, click “survey settings”.  Note the url and replace “survedit.aspx” with “ViewType.aspx” and open the page. You’ll now see the standard list view creation page and can begin creating your own custom view.

Your custom view won’t appear as a choice in the view section of the settings page (which is hidden),  but it will appear in the view choices link up at the top right of any view page.

My rss feed is empty?

Another annoying omission in survey lists is the availability of the rss feed url. Normally, if rss is enabled in the list settings, you’d click the rss icon in the settings ribbon to see the feed and grab the feed url. Not so in a survey list, where the ribbon doesn’t appear and the rss icon under “Actions” opens an empty feed. It looks to me like the url generated there is missing the view guid and so is empty, and most likely a bug.

If you want the correct feed url,  open the appropriate view page, edit it, open the web part properties and click “edit current view”. To the right of the “web address of this view” url, you’ll see a tiny rss icon which, if clicked, will reveal the correct feed from which you can get the feed url. In this case the page name is “listfeed.aspx”, so you can also manually combine that with the list and view GUID’s to get the feed url:

/_layouts/15/listfeed.aspx?List=LIST GUID&View=VIEW GUID

The last survey question about Sharepoint surveys

The only remaining mystery about survey lists in Sharepoint Online is what benefit Microsoft sees in hiding the ability to create views and get rss urls….feel free to comment if you want to tackle that one!

Hide header row in “custom” style list views, retain it in “default” style – Sharepoint Online (2010-13)

The “style” option in Sharepoint list view settings allows you to apply a different template to your list view. But when you use any style other than “default”, the header row just doesn’t belong. With the “boxed” or “newsletter” style, the headings are misplaced and look like a mistake. If you don’t want to mess with the xsl underlying these templates, many Sharepoint sme’s recommend hiding the header row by applying this simple css rule:

.ms-viewheadertr{display:none;}

It’s a good practice to add that to a site stylesheet so you don’t have to insert it on every page where you want to remove the header. What the Sharepoint experts I’ve seen writing about this don’t tell you, is that rule will also get applied to the default style, where you probably want to keep it.

Luckily, a quick browser inspection reveals that among the morass of code used to generate list view web parts, the default style has a class not used on the other list view styles. So with one more line of css added to a site stylesheet, you can hide the header where it’s not needed and retain it where it is:

.ms-viewheadertr{
display:none;
}
.ms-viewheadertr.ms-vhltr{
display:table-row;
}

Fixing the date archive page in a Sharepoint Online 2013 blog site

Categories, date archive pages not filtering posts?

It’s a common problem: the category and date archive pages  on a Sharepoint blog site stop working and users see all posts instead of a filtered view.  It’s easy enough to insert a new “blog tools” web part (which a well known bug breaks if you edit the category.aspx or date.aspx pages). If that doesn’t do it, there are several articles about how to fix the category page – like this one: blog.hametbenoit.info/Lists/Posts/Post.aspx?ID=584

The fix involves restoring a CAML query that Sharepoint mysteriously strips out. The same approach applies to the date archive page  but the specific query is different and hasn’t received as much attention, so I thought it worthwhile spelling out what needs to be done.

Restoring the missing CAML query

In Sharepoint Designer, open your blog site and navigate to the date.aspx page in the posts list.

It’s always a good idea to make a quick copy of ANYTHING you edit in Sharepoint, before diving in. Then, edit it in advanced mode.

Do a search for “<Query><OrderBy><FieldRef Name=”PublishedDate” ” to locate the section of the posts list view web part that needs to be edited.

After the closing orderby tag  “</OrderBy>”, add the following CAML query:

<Where><And><And><Geq><FieldRef Name=”PublishedDate”/><Value Type=”DateTime” IncludeTimeValue=”TRUE” StorageTZ=”TRUE”><GetVar Scope=”Request” Name=”StartDateTime”/></Value></Geq><Lt><FieldRef Name=”PublishedDate”/><Value Type=”DateTime” IncludeTimeValue=”TRUE” StorageTZ=”TRUE”><GetVar Scope=”Request” Name=”EndDateTime”/></Value></Lt></And><Eq><FieldRef Name=”_ModerationStatus”/><Value Type=”ModStat”>0</Value></Eq></And></Where>

It should look like this:

Click to enlarge »

Since this is generic code with no guid’s, and doesn’t appear to have changed much over the years, it’s “safe” to use and  should work in any blog site in any version of SP.

Now, save the page, open it in the browser, restore the “blog tools” web part which will inevitably be broken and check that your filtering is working again.

The straw that broke the CAML’s back

WHY the CAML query gets stripped out remains a mystery and is another example of the questionable development standards in Sharepoint, the platform’s fragility and Msft’s lack of focus on the user experience. But at least now there’s a quick and easy fix.

 

 

Add A Discussions List With Threaded View In Office 365 2013 Sharepoint Sites

discuss-2010A discussion board without a threaded view is like, well….having a blog on one site and its associated comments on another. You never know who’s replying to what. What makes Microsoft’s decision to remove the threaded view from Sharepoint 2013 even odder is that it worked fine in 2010 and still does in a 2013 site. All you have to do is save a discussion list as a template from a 2010 site and move it over.

If you want to add the list to a public site, you may find the template doesn’t show up when you click”add an app”. To workaround that restriction, try installing it on a sub site of the public site. Sub sites can be created with standard templates, so are not as restrictive as the public site. And it’s easy to make a sub site look like it’s part of the parent site by following this guide:
http://365.webbrewers.com/blog/Lists/Posts/Post.aspx?ID=29

If you don’t have access to a 2010 site or want to save some time, you can download the 2010 template here » Just follow the installation instructions on that page.
I set up a working demo of the list on a 2013 public sub site here » You can add some styling if needed to dress it up a bit.

Questions?

Visit my forum » if you have any questions. For development work, you can contact me here ». And if you think this would be useful to others, feel free to share it by clicking one of the share buttons up top!

FREE List Template And Web Part Downloads For Office 365 Sharepoint Online Sites!

111213_0003_addmultiple1Download these free list templates and web parts and add functionality and usefulness to your Sharepoint sites!Easy: download, extract and install!
Time saving: fully functional out of the box!
Safe: developed in a Sharepoint site – no additional code added!

Installation Instructions:
1/ Download file or zip file (and extract)

2/ Open”list template gallery” on desired site [If not in settings, use this url: yourdomain.com/_catalogs/lt/Forms/AllItems.aspx]

3/ Click”upload document” and navigate to the location the .stp file was saved in.

4/ Click the”cog” icon at top right of page and “Add An App”

5/ Locate the app you uploaded and add to your site

Downloads.

Calendar Creator List Template Tested: SP 2010/2013

This free list template will let you add a list and simple calendar web part to Sharepoint Online 2013 public web sites.
Read more »

Download Here »
Announcements List Template Tested: SP 2010/2013

Add An Announcements List To An Office 365 Public Site With A Date Range Filter
Read more »
Download Here »

2010 Discussions List Template Tested: SP 2010/2013
Includes the all important threaded view missing from 2013!
Read more »
Download Here »

Picture Library Slideshow Webpart Tested: SP 2010/2013?

This free web part will let you add a slideshow that pulls images from a picture library..
Read more »

Download Here »
Content Query Webpart Tested: SP 2010/2013?
This free web part displays content from another SP location..
Read more »
Download Here »

Script Editor Webpart Tested: SP 2010/2013?

This free web part allows you to add scripts to a SP page.
Read more »

Download Here »

RSS Feed Viewer Webpart Tested: SP 2010/2013?

This free web part displays content from any RSS feed, including Sharepoint feeds from other sites..
Read more »

Download Here »

Questions?

Visit my forum » if you have any questions. Another thing: use this template for managing goods supply, if needed. For development work, you can contact me here ». And if you think this would be useful to others, feel free to share it by clicking one of the share buttons up top!

Add An Announcements List To An Office 365 Sharepoint Public Site With A Date Range Filter

news-page2A Sharepoint Announcements list can be used to show news items, upcoming events, product introductions or any manner of short update-type items. For some reason, Msft decided not to include this type of list in the public site, and made it rather difficult to add it. Only certain types of list can be added as apps. Even if you import an announcement list template from a team site, Msft prevents it from showing up as an app you can add.Not to worry – since it’s actually a pretty simple list to create, I’m going to show you how to do that – and go one better by enhancing the basic list by adding filters so the list ONLY shows items within a specified date range. You can see a live example of the end result here »Download
If you want to skip all the fun of creating your own list (!), you can download a convenient list template here »

Create The List

Click “Add An App” and create a new custom list, naming it “News” or whatever you want.
Open the list and add list fields by clicking “create column”

create-column

Add a multi line rich text field for your announcement’s content, and 2 date fields – one for “Start date” and one for “Expiry date”.
It will look like this when you open the list’s settings:

fields

Create A Date Filtered View
The default announcements list includes an expiry date field – your custom version can go one better by adding a start date. There are many reasons you may want an announcement to become visible on your site at a specific time – if you’re running a promotion for instance. You may also want announcements to automatically drop off the public view, say after an event is over. To do that, you’ll need to create a new view of the list filtered to only display items between the start and expiry dates you set in the list.
Go to the list settings, click “Create view” and select “All items” as the starting point.

Name the view and make sure only “title” and “body” are checked
Scroll down to the filter section, and add filters as shown in the image:

news-filters

The logic of the filters may seem a little odd – I’m still not sure I understand why it works – but it does. What it says in simple terms is show only items between the start date and expiry date. In more detail, it’s saying:
Show items IF:
Expiry date is equal to nothing = when the expiry date is empty (ie there is no expiry date)
OR
Expiry date is greater than or equal to [Today] = when the expiry date is today or after today
PLUS
Start date is less than or equal to [Today = ]the start date is today or after today.
Any item that fails to meet ALL those conditions will not be shown.

View Style
To give the announcements a vertical rather than horizontal presentation, you can change the style of the view.
Scroll down the list view settings page and open the “style” option
For a vertical orientation, select the “newsletter no lines” style.
Don’t forget whenever you change the view you have to go back and reselect it in the web part properties on the page!

Add To A Page

Now the list is built, you can edit a page, look for the web part with the name of your list under “Apps” and insert it where you want it to appear. You’ll just need to switch over to your custom view as follows:
Click the web part and in the ribbon click web part “properties”.
When the properties box opens, under “List views » selected view” pick the new view you created from the drop down.
Click ok to save your changes and remember to publish the page.

views

Add a few items to the list, and play with the date fields to test it out. Anything with a start date of today or after today AND an expiry date of today or before today should show up on the page.

Additional Points
By default, the”title” field is linked to the item but since Msft blocks anonymous access to list items, you may want to change the type of the title field from “title-linked to item” to just “title”. You can pick a different field type in the list view settings. This wi

Adding A Dropdown Filter To Improve List Navigation In Office 365 Sharepoint Online 2010 & 2013

Sharepoint lists/libraries include various filtering options to help users find what they’re looking for. But the built in, “Excel” like filters and the default form filter web parts aren’t very intuitive or convenient. A drop down menu of options would be more user friendly, and it’s doable by customizing the simple html form filter.
021214_1430_addingadrop1
The Steps:
Add a filterable meta data column to a list.
Insert the form code needed for the drop down menu.
Connect the form filter to the list.
Here are some examples:
2010: http://365.webbrewers.com/SitePages/Eng%20Capstone%20Test.aspx
2013: http://365new.webbrewers.com/Site%20Pages/Text%20filter.aspx
Prepare the List
If your list/library doesn’t already have it, you’ll need to add the column you want to filter on
You can use “category” or any other meaningful meta data term
Open the list settings and create the column, and ensure it’s included in the view you will use
Prepare the Page
On any public or private site page, insert the list view web part
Choose the location you want, and insert an “HTML Form Filter Web Part”
Add The Code

021114_2250_addingadrop1

Open the form filter web part properties
Click “Source Editor” and add your form code in the dialog box
You can use any code but the lines in red below are REQUIRED for the form to work.
Also the option values MUST MATCH the values defined in your meta data column in the previous step.
The optional last line is a trick to clear any filters by refreshing the page.
Sample code (tags removed):

div onkeydown=”javascript:if (event.keyCode == 13) _SFSUBMIT_”
select name=”Media”
option value=”Painting” selected=”selected”Painting/option
option value=”Drawing”Drawing/option
option value=”Print”Print/option
option value=”Charcoal”Charcoal/option
option value=” “*Reset All*/option/select
input type=”button” value=”Go” onclick=”javascript:_SFSUBMIT_”/
/div
a href=”http://365new.webbrewers.com/Site%20Pages/Text%20filter.aspx” Clear All filters!/a


Clear All filters!
Connect The “Dots”!
Next you have to pass the selected value to the list and execute the filtering
Click the down arrow for the filter web part to open a context menu
Click “connections” and select “provide form values to” – when your list name appears, select it.

021114_2250_addingadrop2

If you see a warning about “prevent opening new dialog boxes…” just click cancel.
In the dialog box that opens, there are 2 options:

021114_2248_addingadrop3

1. Choose connection: select “get filter values from” and click the “configure” button

021114_2248_addingadrop4

2. Configure connection: “provider field name” would be the field you defined in the code above (“media” in that example).
The “Consumer field name” presents a drop down of all the list’s fields so select the meta data column you want to filter on.
The value selected will be what gets used to filter the list.
Click “Finish” and the connection is set.
Adding Multiple Filters
To further fine tune the filtering you can add more form filters connected to different columns, allowing the selection of quite specific results. In this example, for instance, filtering is done on “Institution, “Discipline” and ….any other parameter.
Questions?
Please visit our forum »

Open List Links In A New Window Without Code In Office 365 Sharepoint Online

A basic functionality missing from Sharepoint Online libraries/lists is the native ability to open links in a new window. If you have publishing features enabled, you can add the awkwardly named “Hyperlink with formatting and constraints for publishing” column to your list. For non publishing sites and if you’re comfortable adding code using Sharepoint Designer, try these options:Global (every external link)Add this jQuery snippet to your master page:

$j(‘a[name^=”http:”], a[name^=”https:”]’).not(‘[name^=”http://your.domain.com/”]’).attr(‘target’,’_blank’);
Replace”your.domain.com” with your own domain.
Place the snippet before the tag for best results.
Requires that you have the jQuery library running on the site.
List specific links
Take a look at “Open links in a new window in Sharepoint lists” here in this blog. Otherwise an easy, no-code option is to use the little known Summary Links web part.
The downside is this web part doesn’t expose an editable list, so you can’t add columns, views and so on. The only thing you can add other than a link is an image. But for a simple list of links to documents, web pages or list items, this is the easiest solution. It works in every type of site (public/team) and every type of plan I’ve been able to test.
The Steps.
First, check to make sure the summary links web part is in the web part gallery of your site.
Site settings » web designer galleries » web parts ( or for public sites, add this to your domain name: /_catalogs/wp/For).
If you don’t see it, you can get it here» and upload it.
Then, open a page for editing
Click “insert” and under the “content roll up” category, look for “summary links”.
Add a new link: you can browse, or enter a url for any hosted item-document, web page, image etc.

112713_0303_openlistlin1

Be sure to check “open in new window”

112713_0256_openlistlin2

To change the web part title, click edit web part properties, and edit title where it says “summary links”.

112713_0141_openlistlin3

Save the page.
You’ll only see the editing tools when editing the page – regular visitors won’t see them.
What you’ll end up with is a flat list of links that looks like the example below. You can group items together and there are some limited styling options which you can see a few examples of in the left sidebar here:
http://365new.webbrewers.com/Pages/wiki.aspx

112713_0256_openlistlin4

Don’t Have The Summary Links Web Part?
Download it from here »

Questions?

Visit my forum » if you have any questions. For development work, you can contact me here ». And if you think this would be useful to others, feel free to share it by clicking one of the share buttons up top!