Hi. I encountered some issues with the $().SPServices.SPListNameFromUrl function because in SharePoint 2013 the list url can have another form.
Traditionnal form :
DOMAIN/sites/WEB_SITE/Lists/LIST_NAME/PAGE.aspx
In that case the function has no problem.
Other form :
DOMAIN/sites/WEB_SITE/_layouts/15/start.aspx#/Lists/LIST_NAME/PAGE.aspx
In that case the function fails.
To get around I get the list name from the url and use 'GetList' to retrive the list and the guid.
Next the code I used, maybe you improve the function with it.
```
// Constants
var URL_LIST = '/Lists/';
var CHARACTER_SET_LIST = '[a-zA-Z0-9%\\s]';
// Get list name
var listName = null;
var regexp = new RegExp(URL_LIST + '(' + CHARACTER_SET_LIST + '*' + ')/');
var result = url.match(regexp);
if (result != null) {
if (result.length >= 2) {
listName = unformatString(result[1]);
}
}
// Get list GUID
var listGuid = null;
if(listName != null){
$().SPServices({
operation: 'GetList',
async: false,
listName: listName,
completefunc: function (xData, status) {
var found = false;
if (status == 'success') {
$(xData.responseXML).find("List").each(function () {
if (!found) {
listGuid = $(this).attr('ID');
found = true;
} else {
console.log('list already found, only first list evaluated');
}
});
} else {
console.log('query failed');
log.error(status);
log.warning(xData.responseText);
}
}
});
}
```
Traditionnal form :
DOMAIN/sites/WEB_SITE/Lists/LIST_NAME/PAGE.aspx
In that case the function has no problem.
Other form :
DOMAIN/sites/WEB_SITE/_layouts/15/start.aspx#/Lists/LIST_NAME/PAGE.aspx
In that case the function fails.
To get around I get the list name from the url and use 'GetList' to retrive the list and the guid.
Next the code I used, maybe you improve the function with it.
```
// Constants
var URL_LIST = '/Lists/';
var CHARACTER_SET_LIST = '[a-zA-Z0-9%\\s]';
// Get list name
var listName = null;
var regexp = new RegExp(URL_LIST + '(' + CHARACTER_SET_LIST + '*' + ')/');
var result = url.match(regexp);
if (result != null) {
if (result.length >= 2) {
listName = unformatString(result[1]);
}
}
// Get list GUID
var listGuid = null;
if(listName != null){
$().SPServices({
operation: 'GetList',
async: false,
listName: listName,
completefunc: function (xData, status) {
var found = false;
if (status == 'success') {
$(xData.responseXML).find("List").each(function () {
if (!found) {
listGuid = $(this).attr('ID');
found = true;
} else {
console.log('list already found, only first list evaluated');
}
});
} else {
console.log('query failed');
log.error(status);
log.warning(xData.responseText);
}
}
});
}
```