CascadeDropDowns: Any way to pass more than 1 additional filter?

Mar 18, 2011 at 8:29 PM
Edited Mar 18, 2011 at 8:37 PM

I would like to be able to filter the relationshipList on more than 1 value, but when I add the 2nd <Eq></Eq> phrase, an error is thrown on the relationship List. (basically "relationshipListParentColumn: Role or relationshipListChildColumn: Title Not found in relationshipList: Training List"). Since the dropdowns work when I use either of the filters, I know that the error is misleading.  The passed CAMLQuery looks correct with the 2 filters,

Coordinator
Mar 19, 2011 at 3:48 AM

rqcranor:

Can you post your code so that I can try something similar on my end to test? There are a number of things which get built up into the CAML which ends up being sent to the Web Services, so it may be a matter of getting the syntax right, or I may have built things so that this won't work correctly. Either way, I'd like to try to help you figure it out.

Thanks,
M.

Coordinator
Mar 19, 2011 at 4:00 AM

p.s. I'm doing a little testing on this, and at the very least the error I'm giving you may be incorrect. If your CAMLQuery option isn't valid, you'll get the

"relationshipListParentColumn: Role or relationshipListChildColumn: Title Not found in relationshipList: Training List"

type of error. The reason for the error can actually be bad CAML (as I was able to easily generate!).

M.

Coordinator
Mar 19, 2011 at 4:15 AM

Ok, I just got this running. This is my Regions -> States connection. In my States list, I have a Yes/No column called Active. I added a filter so that I only return Massachusetts. and it works.

   $().SPServices.SPCascadeDropdowns({
    relationshipList: "States",
    relationshipListParentColumn: "Region_x0020_Name",
    relationshipListChildColumn: "Title",
    CAMLQuery: "<And><Eq><FieldRef Name='Active' /><Value Type='Boolean'>1</Value></Eq><Eq><FieldRef Name='Title' /><Value Type='Text'>Massachusetts</Value></Eq></And>",
    parentColumn: "Region",
    childColumn: "The State",
    debug: true
   });

M.

Coordinator
Mar 19, 2011 at 4:18 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Mar 19, 2011 at 2:13 PM
Edited Mar 19, 2011 at 2:28 PM

Here is the call that gives me the error

  $().SPServices.SPCascadeDropdowns({
   relationshipList: "Training Curriculum",
   relationshipListParentColumn: "Role",
   relationshipListChildColumn: "Title",
   parentColumn: "Role",
   childColumn: "Course Completed",
   listName: $().SPServices.SPListNameFromUrl(),
   CAMLQuery: "<Eq><FieldRef Name='Status'/><Value Type='Text'>Active</Value></Eq><Eq><FieldRef Name='Organization'/><Value Type='Text'>IDM</Value></Eq>",
   promptText: "Choose {0}...",
   debug: true
  });

I added an alert to the SPServices file so I could see the CAMLQuery to make sure it looked correct (closing </And>, etc) and it looks fine. Again, I used each <Eq> on it's own and returned results, but when I put them together is when I get an error.

Now, I am surprised that you included the <And> statements, as I saw those added to the camlQuery field as the query was being built. But I will try that as well.

Coordinator
Mar 19, 2011 at 2:16 PM

You'll need to wrap the two <Eq>s in an <And> to make it valid CAML. As ugly as CAML is, this "wrapping" makes it relatively easy to build up complex CAML statements.

M.

Mar 22, 2011 at 1:49 PM

Marc,

I have a question about when the lookups are > 20 entries. I have noticed that a) the “Choose {0}” is not displayed in the child lists and b) the boxes do not resize to the values. When I was testing with small lists, the child boxes displayed the “Choose {0}” text and then resized as the child values were added. But once I fully populated the relationship lists those 2 things stopped.

Is that the expected behavior?

Robyn Cranor
770-475-4269 Email:robyn.cranor@hp.com

From: sympmarc [email removed]
Sent: Saturday, March 19, 2011 10:16 AM
To: Cranor, Robyn G.
Subject: Re: CascadeDropDowns: Any way to pass more than 1 additional filter? [SPServices:250313]

From: sympmarc

You'll need to wrap the two <Eq>s in an <And> to make it valid CAML. As ugly as CAML is, this "wrapping" makes it relatively easy to build up complex CAML statements.

M.

Coordinator
Mar 22, 2011 at 2:05 PM

Robyn:

SharePoint sets the dropdown sizes (except for the multi-select ones - see $().SPServices.SPSetMultiSelectSizes) based on the data size. I'm not sure why you aren't seeing that.

On the promptText: "Choose {0}...", I actually discourage the use of that. Yes, I put it into the function, but if the user doesn't make a choice, they get an ugly error because SharePoint doesn't understand that as an option. I've left in in for backward compatibility. (I should as this note to the docs, and I will!)

M.

Mar 22, 2011 at 2:34 PM

What is interesting is that when you select the drop down arrow on the selection box THAT list is resized. But just not the destination box on the page. I just wanted to make sure there wasn’t something I was missing on those larger relationship lists. Thanks.

Robyn Cranor
770-475-4269 Email:robyn.cranor@hp.com

From: sympmarc [email removed]
Sent: Tuesday, March 22, 2011 10:06 AM
To: Cranor, Robyn G.
Subject: Re: CascadeDropDowns: Any way to pass more than 1 additional filter? [SPServices:250313]

From: sympmarc

Robyn:

SharePoint sets the dropdown sizes (except for the multi-select ones - see $().SPServices.SPSetMultiSelectSizes) based on the data size. I'm not sure why you aren't seeing that.

On the promptText: "Choose {0}...", I actually discourage the use of that. Yes, I put it into the function, but if the user doesn't make a choice, they get an ugly error because SharePoint doesn't understand that as an option. I've left in in for backward compatibility. (I should as this note to the docs, and I will!)

M.

Coordinator
Mar 22, 2011 at 2:39 PM

Robyn:

I'm not sure what happened to your image, but if you want to send it to me you can do so at marc [dot] anderson [at] sympraxisconsulting [dot] com.

M.