Monthly Archives: September 2015

Conditional formatting in SharePoint 2013 and Office 365

Sometimes the requirement comes up to make conditional formatting in a SharePoint list or document library. There are several ways of achieving this, you can buy a solution, the are several solutions out there providing conditional formatting. Or you can use SharePoint designer etc.

I will describe a simple method using jQuery that will work both on SharePoint 2013 on-premises and on SharePoint online in Office 365.

In this example I created a custom list with a set of columns. One of the columns, “Approve” is a Choice column with a couple of choices , “None”, “Approved” and “Approved under revision”.


These are the choices we will use for our conditional formatting, We will make items tagged with “Approved under revision” a yellow background and items tagged with “Approved” a green background.

Navigate to your list or document library and select Edit Page from the settings menu.

2014-09-18_12h07_34Then click Add a Web Part and add a Content editor webpart to this page. We will use this Content editor webpart to add our jQueryscript.

Click anywhere in the Content editor webpart and then click Edit Source on the ribbon.


Add the following JavaScript to the HTML Source dialog.


01 /code
05     $(document).ready(function(){
07         $Text = $("td .ms-vb2:contains('Approved')").filter(function() {
08   return $(this).text() == "Approved";})
09         $Text.parent().css("background-color", "#00FF66");
11         $Text = $("td .ms-vb2:contains('Approved under revision')");
12         $Text.parent().css("background-color", "#FFFF66");
15     });

Line 1 of the script points in this example to the jQuery library online. In your environment you could just as easily download the jQuery  library form here and put in in a library on your SharePoint or Office 365 site. I usually put it in the Site Assets library and update the URL in line 1 accordingly.

Line 7 searches for a table cell with the word “Approved” in it and uses the filter function to make sure it matches the word exactly since the next item we are looking for “Approved under revision” alos includes the word approved. Once it find a table cell with the word “Approved” it sets the background color for the parent to green. The parent in this case will be the table row so the hole row gets a nice green background color.

Line 11 and 12 does the same thing, without the filter function since we are searching for a match to “Approved under revision”, and sets the background color of the parent to yellow.

Click Ok and the Stop Editing in the ribbon when you have pasted in the script.

The result will look like the screenshot below.


So that was my description of an easy way to get conditional formatting for a list or document library. Works great both in SharePoint 2013 on-premises and in Office 365.


Infopath has removed the submit button from SharePoint list form

Do you want people to be able to quickly fill in a form on your site, over and over again?  One option for this has always been datasheet view, but sometimes you have a more complex form.  In this post, I’ll show how you can create a button that will save the current record and immediately go to a new blank form.

In this example, I’ll just use a simple announcements list.


  1. Go to your announcements list. On the List tab, click the button Customize Form.
  2. Put your cursor at the bottom of the form where you want to put your buttons.  From the list of Controls in the ribbon, add two buttons to the form.
  3. On the Data tab, click the Submit Options button.  Click the Advanced button.
  4. Next to After submit, choose Open a new form.  Click OK.
  5. Double-click to select the first button, and in the ribbon, click Manage Rules.
  6. In the Rules pane on the right, click the New button and choose Action.
  7. In the Details for box, type Submit. Click the Add button and choose Submit Data. Select your data connection to submit to.  This example is a SharePoint list, so it automatically has the one called “Main Data Connection”.  Click OK.
  8. Click Add again, and choose Close the form.  Click OK.
  9. In the Properties tab of the ribbon, label this button as SAVE.
  10. Double-click to select the second button still labeled “Button”.  Find the Action drop-down box in the ribbon.  Change the action to Submit.
  11. Change the button label to say Save & New.
  12. Publish the form and close InfoPath.

Done!  Now, if you want to make it look pretty and professional, use picture buttons instead of those old gray ones.  I like to use PowerPoint to create buttons and make them PNG files.

ONE NEGATIVE to this solution:

If you’re using a SharePoint list form customized with InfoPath, you’ll still have the save button in the ribbon.  That Save button will do the “save and new” functionality, and there is not a way to change this without messing up this solution.  One option you have is to remove the ribbon altogether.  Click File and click the Form Options button.  On the Web Browser tab, uncheck the box next to Show InfoPath commands in Ribbon or toolbar.  Unfortunately, when you do this, there won’t be an edit button there on the form either, and the only way people can get to the edit screen will be to use the drop-down box on that item when in the list view, or use the ribbon when in list view.