GetListItems, bookmarklets and permissions?

Nov 10, 2010 at 3:07 AM

Hi Marc,

I've been working on a bookmarklet that uses SPServices to access a SharePoint list containing bookmarklets and deliver them via a JQueryUI driven dialog. The idea being to allow users to access a central bookmarklet repository, using the one bookmarklet. This mechanism could then evolve to dynamically deliver other types of SharePoint content aswell. 

The bookmarklet fires successfully if run from within the same site collection as the list that stores the other bookmarklets, but the GetListItems method doesn't return anything if I run it from outside that site collection. I am specifying the full url as one of the parameters but still no luck.

My thoughts are that it is a permissions issue. The script creates a new div on the page the bookmarklet is run from, and the SPServices scripts are run within it, before .dialog is called on the div.  

Is it possible to use SPServices to do this from outside the site collection or is it a lost cause?

I've attached the part of my code that calls GetListItems for posterity.

  $().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "Bookmarklets",
    webURL: "http://departments.sp.common.local/cbs/emw/",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='Script' /><FieldRef Name='Description' /></ViewFields>",
    CAMLQuery: "<Query><OrderBy><FieldRef Name='Category' Ascending='True' /></OrderBy></Query>",
    completefunc: function (xData, Status) {
      $(xData.responseXML).find("[nodeName=z:row]").each(function() {
        var row = "<tr>" + "<td style=\"font-family:tahoma;color:black;font-size:16px\">" + "<a href=\"" + $(this).attr("ows_Script") + "\">" + $(this).attr("ows_Title") + "</a>" + "</td>" + "<td style=\"font-family:tahoma;color:grey;font-size:12px\">" + $(this).attr("ows_Description") + "</td>" + "</tr>";
        $("#BookmarkletList").append(row);
				});		
			}
		});	

thanks,

Sunny

Coordinator
Nov 10, 2010 at 3:24 AM

Sunny:

Unfortunately, there are a lot of variables in network topology that can impact your ability to get at content in other Site Collections. In *theory* it is possible, but in *practice* there are often issues. It's hard to say what your issue might be.  (I am in no way an expert on that layer of things.)

Do you get anything back from the call into the other Site Collection at all? A SOAP response at least?

M.

Nov 10, 2010 at 4:17 AM

I'm not really sure how to debug that, Marc, is there maybe a tool you could point me towards? IE does register an 'access denied' error in my script though if that is any help.

Coordinator
Nov 10, 2010 at 4:20 AM

The simplest debugging thing you can do is to just alert the response like this:

alert(xData.responseXML.xml);

If you're getting a SOAPResponse back, that alert should show some XML. If not, you'll get "undefined' or something.

M.

Nov 10, 2010 at 5:06 AM

Hi again Marc, I placed the alert at the top of the completefunc and it doesn't fire from outside the home site collection. 

The access denied error is in line 127 of the minified JQuery 1.4.2:

e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async)

I guess it's a no go?

Coordinator
Nov 12, 2010 at 1:40 AM

This is a tough one for me to advise on from here, frankly. I'm really not sure what to suggest other than seeing if you can reach the endpoint in some other way just to test if it's something in SPServices or in jQuery itself.

M.

Nov 12, 2010 at 5:32 AM

Thanks anyway Marc, appreciate your time.

Dec 24, 2010 at 10:51 AM

Hi guys,

have you found a workaround regarding this issue?

Thanks!