Getting going with SPServices.SPCascadeDropdowns

Jul 24, 2013 at 12:36 AM
Edited Jul 24, 2013 at 12:37 AM
Have just started using SPServices (so be gentle, please) with SP Online/O365 (SP 2013) and am trying to get started with the SPCascadeDropdowns function; nothing too fancy, just trying to get a 'hello world' level event achieved, but am not getting any results. I am using jquery-1.10.1.min.js (my own minified copy) and jquery.SPServices-2013.01.min.js

My list relationships are as follows:

Branch list (List name: Branch) containing 'Branch Name' (display name = 'BranchTitle', static name = 'Title')

Job list (List name: Job) containing 'Job Title' (display name = 'Job Title', static name = 'Title') - job titles will be unique

Branch Job list (list name: BranchJob) containing SP lookup columns to 'Branch' (source: Branch) (display name = 'Branch', static name ='Branch') and Job Title (source: Job)(display name = 'Job Title', static name = 'Job%5Fx0020%5FTitle', which I have translated to 'Job_x0020_Title').

The purpose of the Branch Job list is to provide a valid list of jobs at each branch.

Now to the nub of my request for assistance.

I am customising a new list form which I want to:

a) filter the list of available branches based on a user's profile (I'm planning to use the 'SPServices.SPFilterDropdown' function for this later), and

b) once a) is selected I am trying to filter a list of jobs to only those available at the branch selected in a).

Column a) is using a look up column to the Branch List and column b) is using a look up column to the Branch Job list

The code I have got so far is:
$().SPServices.SPCascadeDropdowns({
      relationshipWebURL: "",
      relationshipList: "Branch Job",
      relationshipListParentColumn: "Branch",
      relationshipListChildColumn: "Job_x0020_Title",
      relationshipListSortColumn: "",
      parentColumn: "Branch", //column display name in my new list form
      childColumn: "Position Required", //column display name in my new list form to hold the job title
      CAMLQuery: "",
      CAMLQueryOptions: "<QueryOptions><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns></QueryOptions>", // Added in 2013.01
      listName: $().SPServices.SPListNameFromUrl(), 
      promptText: "",
      simpleChild: false,           // Added in v0.6.2
      selectSingleOption: false,        // Added in v0.6.2
      matchOnId: true,          // Added in v0.7.1
      completefunc: null,
      debug: true
    });
I haven't sought to pre-filter my column a) yet, so I can better test the column b) when I change the branch, so a) still has the results of the generic lookup column settings, but column b) is not returning any values at all. I have tweaked various parameters in my code without success.

I'm sure it's going to be something simple, and I'm happy to receive some tough love, but could really use some advise as to where I'm going wrong!

Thanks
Coordinator
Jul 24, 2013 at 3:16 AM
I think the issue is your list structures. Is each job only available in a single branch? My guess is not, which means that you have a many-to-many relationship. The function won't handle that for you, generally.

Take a look at the Country / Region / State example in the documentation; it ought to help.
https://spservices.codeplex.com/wikipage?title=$().SPServices.SPCascadeDropdowns

M.
Jul 24, 2013 at 11:44 AM
Hi Mark and thanks for your quick reply.

It would seem that either I was ambiguous in the description of my list schema or the SPServices gods are smiling on me. Either way - perhaps helped by my publishing a major version of my .js file - the filtering I was looking for in my requirement b) works!

So, problem solved, but I'm sure there'll be others.
Coordinator
Jul 24, 2013 at 2:16 PM
Great!

M.