Spaces in list names

Sep 14, 2010 at 2:13 AM

Hi,

Lists with spaces in the name aren't working for me...I tried putting %20 where the spaces are but that didn't resolve either...

$().SPServices({

                operation: "GetListItems",
                async: false,
                listName: "Blitz Approved", // what to put here?
                CAMLViewFields: "<ViewFields><FieldRef Name='Type' /><FieldRef Name='Name' /><FieldRef Name='Code' /></ViewFields>",
                completefunc: function(xData, Status) {

Is there something magic to make it work (escaping, special character)? Or should the names simply not contain spaces...I should be able to rename them without spaces...but the site won't be used by tech people so that will likely confuse them!

I do not want to use the GUID path because I am creating a javascript frontend only which should work across different sharepoint environments (Dev, Test and Prod) and the GUIDs will likely (presumably) be different in each site...but the names of lists are Business decided so are static across each

Thanks heaps! David.

Coordinator
Sep 14, 2010 at 2:27 AM

Yes, if you're trying to use code across multiple platforms, the GUIDs will be different.

SharePoint uses your display name (the one with the Space in it) just to present the list name to you; on the back end it trims it.

If you load SharePoint designer and go to the Lists folder for your site, you'll see the display name of the list, then in parenthesis you'll see what SharePoint really uses as the list name. In your example, it should be "BlitzApproved", it should have just removed the space, but the best method is to login to SharePoint designer and look at it to make sure that's what it is.

Sep 14, 2010 at 3:13 AM

Thanks for the quick reply!

That's good to know that the space is trimmed, I did try the list name without the space and it still isn't working (getting the GUID error)...

I don't have access to the SharePoint designer, but from memory, I can use the SPServices library to find the name if I know the GUID...if the name isn't going to be the same in different instances, I may as well code a solution with stored GUIDs instead of stored Names...

Thanks again!

Coordinator
Sep 14, 2010 at 2:34 PM

Yes, if you're an admin, which it sounds like you are, you can call the GetLists operation and use that to dump out a list of the list names and GUIDs.

Sep 15, 2010 at 12:21 AM

Not sure what happened, but after trying the GUID (which worked), I tried the name with the space and it was also working...I must have had a typo I presume!

Coordinator
Sep 15, 2010 at 1:41 AM

Didn't think that the space should have caused a problem. Glad you resolved it!

M.