SPFilteredDropdown does not work for lookup to parent web

Jun 22, 2011 at 4:37 PM

Hi,

I have a problem regarding the use of the filtered dropdown. I placed the whole javascript inside a custum form. This form is placed on a list where there is a Lookup Field pointing to a list in the parent web:

<script type="text/javascript">

    ExecuteOrDelayUntilScriptLoaded(getRelativeUrl, "sp.js");
    
    var relativeUrl;
    function getRelativeUrl() {
	     var ctx = new SP.ClientContext.get_current();
	     this.site = ctx.get_site();
	     ctx.load(this.site);
	     ctx.executeQueryAsync(Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFail));
     }

     function onSuccess(sender, args) {
         relativeUrl = this.site.get_serverRelativeUrl();
	     filterDropDown();
     }

     function onFail(sender, args) {
	     alert('failed to get site. Error:' + args.get_message());
     }


	function filterDropDown(){
		$().SPServices.SPFilterDropdown(
		{
			relationshipWebUrl: relativeUrl, 
			relationshipList: "Ablauforganisation", 
			relationshipListColumn: "Title", 
			columnName: "ProzessReferenz", 
			promptText: "{0} auswählen...", 
			CAMLQuery: "<Neq><FieldRef Name='ContentType'/><Value Type='Text'>Verbinder</Value></Neq>", 
			debug: true
		}
		); 
	} 
    
    </script>

I get the errormessage "Not found in relationship List "Ablauforganisation" - or CAML is incorrect". As parameter it specifies the column "Title".

The list "Ablauforganisation" lies, as stated above, in the parent web and I want to filter it for all items that do not have the contentType "Verbinder". I have checked, if all fields and lists exist by powershell. I have access to the field and the list. The contentType is used for some items.  I also used the GUID variant to secify the relationshipList, but that did not change the result. Also, if I filter a lookup that is liing in the same web, everything is fine. I also gave the callfunc parameter, but that did not change a thing, either.

Do you have any ideas what I have to change? Thanks in advance.

Regards, Urs

 

Coordinator
Jun 25, 2011 at 5:12 PM
Edited Jul 5, 2011 at 4:19 PM

Urs:

It looks like you are using a different language version of SharePoint, and therein may lie the problem. There's no way I can test with all of the available languages, but I have put in fixes as I identify issues with people.

That said, the language may not be the issue. Have you gotten the function to run properly without the CAMLQuery? (Yes, this would simply pull back all of the items, but it would tell us if the basics are working properly.)

Another thing to try would be to hard-wire the value of relationshipWebURL just for debugging.

M.

Jul 5, 2011 at 3:38 PM

Hi Marc,

I have been on vacation recently, therefore the late reply ;-)

To exclude the language as cause for the problem I switched testing from a german to an english sitecollection. Also, I hardwired the url (relativ and absolute) and i left the query blank/out. None of the changes provided another result than the initial.

So, any other ideas about this?

Urs

Coordinator
Jul 5, 2011 at 4:31 PM

What does the value for relativeUrl look like? It should be in the format "/Departments/HR", though it could also be an absolute path.

Is there a column in the "Ablauforganisation" list called "Title"?

This one is going to be tough to debug from afar, so I'll probably ask some seemingly dumb questions. Also, I'm guessing by the code that you are showing above that you are comfortable adding some debugging alerts to SPServices itself. What version are you running?

M.

Jul 5, 2011 at 4:40 PM

I tried with and without leading slash . The "Ablauforganisation" has the default column "Title".

I have been running 0.6.1, but have just upgraded to 0.6.2 to use the ComplexToSimple functionality, which works great, by the way! The upgrade did not change anything.

Coordinator
Jul 5, 2011 at 4:57 PM

Let's see. We've isolated the CAMLQuery, the column name, and the potential language issue. Let's try adding some debugging to SPServices on your end.

In v0.6.2, just below line 1974, add this alert:

alert(xData.responseText);

That should show us the exact error coming back. All I do with the debug mode is look for "faultcode" and if I find it, I show my error message.

M.

Jul 5, 2011 at 5:08 PM

Ok, I have inserted the line and the new errormessage states, that the list does not exist (SoapServerExecption)! The errormessage does not provide the path the function looks at.

The url of the existing list is http://Servername/websites/deutsch2/Lists/Ablauforganisation.

Urs

Coordinator
Jul 5, 2011 at 5:12 PM

And you've said that you hardwired the value like this, right? (You do need the leading slash.)

relationshipWebUrl: "/websites/deutsch2"

M.

Jul 5, 2011 at 5:18 PM

My code at the moment:

$().SPServices.SPFilterDropdown(
		{
			relationshipWebUrl: "/websites/deutsch2", 
			relationshipList: "Ablauforganisation", 
			relationshipListColumn: "Title", 
			columnName: "Prozessreferenz", 
			promptText: "{0} auswählen...", 
			//CAMLQuery: "<Neq><FieldRef Name='ContentType'/><Value Type='Text'>Verbinder</Value></Neq>", 
			//completefunc: null,
			debug: true
		}
		);
Urs
Coordinator
Jul 5, 2011 at 5:21 PM

If you open the site "/websites/deutsch2" in SharePoint Designer, do you see the list being named "Ablauforganisation"? If you rename the list through the UI, the internal name isn't changed. (I'm grasping at straws.) And there aren't any umlauts or anything (letters outside the range a-z) in the list name?

M.

Jul 5, 2011 at 5:29 PM

Yes, there is the list "Ablauforganisation" in the "AllFiles/Lists" folder and under "document libraries and lists".

It is named "Ablauforganisation" and it's title is "Ablauforganisation", too. So, no umlauts, either... I have double checked with SharePoint Manager and there it is the same.

Urs

Jul 5, 2011 at 5:41 PM

I have inserted an additional alert into the line after the one you gave me:

alert(opt.relationshipWebUrl + opt.relationsipList);

This alerts the following: "/websites/deutsch2undefined".

Jul 5, 2011 at 5:43 PM

Damn, that was too fast! I have a typo in that alert:

it states "/websites/deutsch2Ablauforganisation". So the parameter seems to be allright.

Urs

Coordinator
Jul 5, 2011 at 5:43 PM

You're missing the "h" in opt.relationsipList. :-)

M.

Jul 5, 2011 at 6:13 PM

Another try:

I added two additional alerts as follows:

// Get information about columnName from the current list
		$().SPServices({
			operation: "GetList",
			async: false,
			listName: opt.listName,
			completefunc: function(xData, Status) {
				alert(opt.listName);
				alert(xData.responseText);
				$(xData.responseXML).find("Fields").each(function() {
					$(this).find("Field[DisplayName='" + opt.columnName + "']").each(function() {
						// Determine whether columnName is Required
						columnColumnRequired = ($(this).attr("Required") === "TRUE") ? true : false;
						// Stop looking; we're done
						return false;
					});
				});
			}
		});

This is from line 1943. The resulting alerts are

  1. empty!
  2. The same errormessage as before

 Does this help?

Urs

Jul 5, 2011 at 6:19 PM

Answer: no ;-) It is just the column in the local list. Reading thoroughly helps...

Coordinator
Jul 5, 2011 at 7:31 PM

I'm still not sure what's going on. If you can continue debugging on your end, that might be the most productive next step.

M.

Jul 6, 2011 at 8:03 AM

I will do that. Thanks very much for your help!

Urs

Jul 15, 2011 at 8:16 AM

Hi,

after some more debugging I found out, that the ajaxUrl is set to the childweb when trying to read data from the parentweb. I do not know, if the SharePoint webservice may have a problem with this...

Nevertheless, I reverted to list ID again, and: TADA! The filter works flawlessly. I guess I had an error in my caml when I tried out the GUID the first time! As the list ID is fixed (at least at the moment) I can live with this outcome perfectly. I will try to grab the ID before I start the filter, so I this gets a bit more dynamic.

Thanks again for your help and for this great framework!

Urs

Coordinator
Jul 15, 2011 at 3:36 PM

Urs:

Glad you got it sorted.

M.