SP Services SPGetCurrentUser Error

function getCurrentUserInfo() {
var thisUsersValues = $().SPServices.SPGetCurrentUser({
fieldNames: ["ID", "Name", "Picture", "Email"],
debug: false
});
var name = thisUsersValues["Name"];
var userPic = thisUsersValues["Picture"];
}

But I was getting this error in Internet Exporer, everything worked fine in Chrome:

SCRIPT438: Object doesn’t support property or method ‘replace’

File: jquery.SPServices-2014.01.js, Line: 2414, Column: 17

In Chrome I looked at the values being returned for the user and I noticed that the ID value always came back empty. In the application I was working on I did not really need to use the users ID because the username/email are enough to find the users profile.  So I removed ID from the list of field names and everything started working again. If I needed to get other information about the user it is possible to just call this spservices function using the username from the code above.

 

Hope this helps someone.

SPServices Retreiving and Filtering Data

I could not find a good example of how to do this so here is my solution. Hopefully it will be helpful to someone. Here is a quick example of how to retreive data from a list with SP services and then filter the results before displaying them. In my example I needed to get the data from a list but display part of it in two different places on the page

// normal sp spervices call to the list 
function getFooterLnks() {
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Links",
completefunc: function(xData, Status) {
// this function runs on the data we get back    
    getDataFooter(xData, Status,colArray);
}
});
}

function getDataFooter(xData, Status) {

// putting the data into a Json object 

var myJson = $(xData.responseXML).SPFilterNode("z:row").SPXmlToJson({
mapping: {
ows_Title: {mappedName: "Title", objectType: "Text"},
ows_Column: {mappedName: "Column", objectType: "Text"},
ows_Url: {mappedName: "Url", objectType: "Text"},
ows_Cat: {mappedName: "Category", objectType: "MultiChoice"}
},
includeAllAttrs: false
});

// now we need to filter the Json object the col variable holds the term I want to filter by

var col = "Category 1";

// check if the value appears in the Json

myJsonResults = $(myJson).filter(function(){
return this.Category[0].indexOf(col) !== -1;
});

// put each of the results in an object with html formatting

var items = [];
$.each(myJsonRes, function() {
items.push("
<ul>
	<li><a title="" href="&quot; + this[">" + this['Title'] + "</a></li>
</ul>
&nbsp;

");
});

");
});
$('#linksWrapper').append(items);

}
SharePoint News Ticker

SharePoint List Driven News Ticker

I have written about making a News Ticker before but it looks like the code is not working anymore so why not make something better. News tickers are a great way to show a lot of information in a small space and they look much better than an annoucements web part. For this example I established a few ground rules.

  • Content will be pulled from a custom SharePoint list.
  • When clicked the items will open in a dialog window
  • The ticker will pause on hover and have controls so users can scroll through the news items
Inline Editing for document libraries

Inline editing in a dataview web part.

inline editing in a DVWP SharePoint 2010

Inline Editing Options in SharePoint Designer

When you create a list view dataview web part in SharePoint 2010 you have the option of enabling inline editing. Once enabled users can edit and create list items without leaving the page. This is nice but by default SharePoint Designer does not style the interface the same way as it is when done in a standard list view. See the example below.

This is not difficult to fix, here is how I did it.

Here is what the standard inline editing interface looks like

default inline editing SharePoint

default inline editing SharePoint
When you use a data view web part it looks like this by default

data view web part inline editing SharePoint
data view web part inline editing SharePoint

Now this interface may look fine to you but I wanted it to look more like the standard interface. To get it looking better requires adding some code to the data view using SharePoint desiger.

search

Visual Best Bets in SharePoint 2010 without FAST

Using visual best bets is a very simple way to make your best bets stand out, if you don’t have Fast Server setup on your SharePoint environment this is not available out of the box. If you have FAST this is a good article on how to setup visual best bets.  For those of us without FAST here is how I did it.

To show best bests on the search results page you will either need to use a search center or create a custom search page and add the best bets web part to it. Here is what best bets look like out of the box.

SharePoint 2010 Visual Best Bets

Visual Best Bets without FAST

  1. Put the page in edit mode and then edit the best bets web part
  2. Click on the XSL Editor button
    SharePoint Edit XSl Button
  3. You can either or the little editor window or copy the code into an editor like Dreamweaver or Notepad
  4. On line 45 you will see this code
    <xsl:value-of select="Description"/>
  5. We are going to change the code to render the description field as HTML and not just plain text. Change the code on line 45 to this:
    <xsl:value-of disable-output-escaping="yes" select="Description"/>
  6. Save the changes to the web part and save the page.
  7. Now we need to setup our best bets to show images. If you dont already have best bets setup you can follow the steps outlined here
  8. Once you have a best bet setup edit it and in the description use HTML to show the image you want to display.
    <img src="URLofImage" alt="description of image"/>

    SharePoint 2010 search best bets setup

  9. Save the best bet and run a test search.

SharePoint 2010 Search best bets with images and no FAST

Visual best bets not only look better than the other results but can allow you to show more detailed information about the result without them having to click. Using this same solution you could include other HTML to show multiple image, the top pages from a site or other information useful to the person searching.

SharePoint Featured Content Slider

SharePoint Featured Content Slider for 2010

SharePoint Featured Content Slider

So I rewrote this web part to work a little better in SharePoint 2010. I made a few minor changes and improvements. If you can think of other improvements put them in the comments. Here is the older version.

Whats new

  • Added an order field to the List template to allow more control of the display order. In the list template this field is setup to require unique values.
  • Re-wrote the CSS to include some new CSS3 enhancements. If you are using a newer browser the slider will look better.
  • Tested across muliple browsers. See screenshots below.
Block multi-document uploads in SharePoint

Block multi-document uploads in SharePoint

Block multi-document uploads in SharePointIn SharePoint 2007 when a document library has required columns for metadata or other information the user is prompted to complete the information when a new document is added. However if the user chooses the ‘Upload Multiple Files” option they are not required to populate required columns. After the files are load and a user goes in to edit they will be prompted to fill in the information.

In some cases this may not be an issue but if the library has workflows triggered by column values or views sorted or filtered based on those metadata columns there could be problems. So of course there is use training that can be done to ensure documents are always properly populated with metadata but sometimes that is not enough.

Some thoughts on #SharePoint Adoption

SharePoint is a powerful tool for collaboration and information sharing. Working on documents, tracking issues, tasks and projects can all be made easier using the tool. In many demos I have seen SharePoint can be used as a complete solution for managing the complete life-cycle of a business process. It all seems so great.

In the real world of actual organizations (at least in my experience) not everyone is willing or interested in using SharePoint. There are ways to integrate external applications with SharePoint that can create very powerful solutions but in some cases the issues is more than just connecting to other data sources. There are cases where you just need to pull information out of SharePoint for a report to management or for a meeting where you will not have access to your SharePoint site.